There are mainly two ways to access a property in JavaScript.
We can access properties of employee object in both ways.
Ex:
In here we won't be able to properties with both notation. Only
- Using dot notation (.)
- Using square bracket notation ([])
var employee={
name:"Antony",
age:26
}
We can access properties of employee object in both ways.
employee.name
employee["name"]
Ex:
var marks={
30:"bad",
70:"good"
}
In here we won't be able to properties with both notation. Only
marks["30"]
will work.
No comments:
Post a Comment