A property consists of a name, a value, and a set of attributes. It belongs to an object.
Since it belongs to an object, each instance of a particular object class can own its own private properties as well as inheriting shared properties from its prototype. Privately owned properties are sometimes called instance variables.
A property can have zero or more attributes. The attributes control how the property is accessed both internally from inside the interpreter and externally from your script.
A property is somewhat like a method, at least in the way it is described in a script. However, properties are containers whereas methods are actions. Properties can have values assigned to them or can have their values retrieved. A method will generally cause something within the receiving object to change. Properties are read only, write only, or read and write. Some properties are internal and private to the object and are not therefore exposed as scriptable items.
Methods are really references to function objects that can be called.
Prev | Home | Next |
prompt() | Up | Property accessor |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |