How can I add a key/value pair to a JavaScript object?

There are two ways to add new properties to an object: Using dot notation: Using square bracket notation: The first form is used when you know the name of the property. The second form is used when the name of the property is dynamically determined. Like in this example: A real JavaScript array can be constructed using either: The … Read more

How can I add a key/value pair to a JavaScript object?

There are two ways to add new properties to an object: Using dot notation: Using square bracket notation: The first form is used when you know the name of the property. The second form is used when the name of the property is dynamically determined. Like in this example: A real JavaScript array can be constructed using either: The … Read more