Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add property to object in javascript

var data = {
    'PropertyA': 1,
    'PropertyB': 2,
    'PropertyC': 3
};

data["PropertyD"] = 4;

// dialog box with 4 in it
alert(data.PropertyD);
alert(data["PropertyD"]);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #property #object #javascript
ADD COMMENT
Topic
Name
2+3 =