Why this works
Why I gave the constructor's custom property such a strange name
The code on page 1 meets the requirement not to create any hard-coded
global names. But it creates a custom property of the
myObjectType. This creates two small
risks of name conflicts:
- A future extension of the ECMAscript standard may add properties to the built-in Function object type, and I can't predict their names.
- A user who knows this technique may wish to create his / her own custom properties of constructor functions, and should not have to read through my code to avoid name conflicts.
So I try to minimize the risk of name conflicts in custom properties of standard objects by following these rules:
- names which are for internal use only begin with _ (underscore), a convention which has worked well in C for decades.
- the next part of the name is my initials, followed by a 2-letter code for the package of which the object is part. This reduces the risk of conflicts with custom properties created by other users who use the _ (underscore) convention--and with custom properties created by other scripts I write!
About the author
Philip Chalmers has worked in IT since the early 1970s (sometimes feels like the 1870s). He has specified, designed, and developed systems on platforms ranging from mainframes to PCs in several languages. His first technical publication appeared in 1979, when he wrote several sections of the Adabas DBA Manual.
Created: November 7, 2002
Revised: November 7, 2002