| |
|
||||
|
Overwriting Overriding is often confused with overwriting, but that is probably more because they are similar looking words than that they are confusing concepts. Overriding is blocking the view, and overwriting is just as it sounds, writing over a property, destroying what is underneath. You probably do not need an example of overwriting (not since you accidentally overwrote that 10MB flash file with a 2K test file), but for the record, here is how it's done: Dog = function( ){} fido = new Dog( ); fido.puffyHair = true; fido.puffyHair = false; Fido had puffyHair, but finally gave in to peer-pressure and got a normal haircut. The previous value is gone, unlike when you overrode a property. If you wanted to remember fido's original hairstyle, you would need a new instance property like fido.hadPuffyHair or something. After all, even old hairstyles 'belong' to the individual, so they should be stored by the individual. That's what high-school yearbooks are for. Overriding < < Home > > Protection |