DEV Community

Cover image for JavaScript Objects
Zouhair Sahtout
Zouhair Sahtout

Posted on

JavaScript Objects

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
Image description


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.

Image description


Adding properties

Adding new properties to the object using both: dot notation and bracket notation

Image description


Operator precedence

In terms of "operator precedence":
. and [] : they have the same precedence which is 17,
and both from left-to-right

Image description

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools canโ€™t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay