In JavaScript, an object is a non-primitive, structured data type used to store various keyed collections and more complex entities.
There is many ways of declaring objects, this one called:
The Object Literal Syntax
There's two different ways of accessing to the properties of an object
Using: dot notation:
console.log(zouhair.firstName);
Using: bracket notation:
console.log(zouhair['lastName']);
Different
The big difference between these two up here, in the "bracket notation" we can put an "expression" - (expression produce a value).
Any time we try access a property on an object does NOT exists we get undefined.
Adding properties
Adding new properties to the object using both: dot notation and bracket notation
Operator precedence
In terms of "operator precedence":
.
and []
: they have the same precedence which is 17,
and both from left-to-right
Top comments (0)