spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / objects To page 1current page
[previous]

How To Create Unique Automatic JavaScript Objects

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Why this works

In JavaScript a function is an object of type Function, and you can treat the function's name as a variable which references the function as an object. So you can give the function object custom properties, just as you can with any other object.

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 constructor function myObjectType. This creates two small risks of name conflicts:

So I try to minimize the risk of name conflicts in custom properties of standard objects by following these rules:

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.

You can email him or check out some of his other ideas at his Web site.


home / programming / javascript / objects To page 1current page
[previous]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: November 7, 2002
Revised: November 7, 2002

URL: http://webreference.com/programming/javascript/objects/2.html