| Applying science to business management |
  
Object Operators
Object Literal {p1:x,p2:y,...}
You can create an object by enclosing a list of property
name/value pairs in braces. For example, {length:3,width:2,height:4}.
This expression creates an object with three properties named length,
width, and height.
new new x()
Another way to create an object is to use the new
operator in conjunction with an object constructor function. See
the chapter entitled Objects
for more detail on creating objects.
Property x.y
Once you have created an object, you can refer to its
properties by placing a period after the object name followed by
the property name. For example, obj.length
references the property named length in the object named obj.
List Element x[y]
You can access an object property using the List Element
operator as well. This syntax is similar to using the Property operator except that the
operand y can evaluate to a
property name instead of being a name literal. For example, obj["length"] is the same as obj.length. This is also equal to obj[y] as long as y is a variable with the value "length".
delete delete x.y
You can delete specific object properties using the delete
operator. For example, the expression delete
obj.length will remove the property named length
from the object named obj.
|