Adding and Deleting Object Own Properties
This section provides a quick description of object's own properties. A tutorial example is provided on how to add, update, and delete object's own properties.
When you create a new object from the "Object" constructor, you will get an object with only two default properties:
But you can add more properties to one object at any time using an assignment operation like this:
object_name.property_name = initial_value;
The added property is for this one object only. Other objects will not have this property.
You can also delete properties from one object at any time using a delete operation like this:
Here is a tutorial example that shows you how to add a new property, update the property value, retrieve the property value, and delete a property.
The result matches my expectation:
mySite.url: www.herongyang.com myBoot.url: undefined mySite.author: undefined myBook.author: Herong Yang mySite.hasOwnProperty("url"): true Deleting mySite.url... mySite.url: undefined
Table of Contents