home / experts / javascript / column80 |
|
Enforcing Object ConstructionThe following code includes a mistake. Can you find it?
You guessed it right. The code is missing the keyword
Calling the first If this check fails, we call the constructor again, this time without forgetting the keyword new. The constructor function Employee becomes:
Try calling init(). You will not get an error, because we create the object for you. Next: How to distinguish between private and public data elements |
URL: http://www.webreference.com/js/column80/7.html