Creating objects
A single object can be assigned a list of properties and values, with a colon between the property and its value and commas separating pairs.
var myCircle = {
x: 50,
y: 50,
radius: 50,
colour: "red"
}
The value of a property can be accessed or modified by using dot notation or by putting the property name in square brackets after the name of the object, as in myCircle['radius']
.
It is also possible to add or delete a property, using assignment for the former and the term delete
for the latter, as shown below:
myCircle.name = "nose";
delete myCircle.colour;
A for loopRepetition a fixed number of times. can be used with in
to process each property in the object, such as for (prop in object)
.
Keep in mind that objects are mutable and are called by referenceThe function uses the input data itself., resulting in aliasingA situation in which two different names are used for the same data..