dem.1797
dem.1797

Reputation: 49

JavaScript difference between curly brackets and square brackets

What's the difference between var = [] and var = {} in JavaScript?

Upvotes: 1

Views: 3607

Answers (3)

hasan
hasan

Reputation: 11

[] : The square brackets are for Arrays. {} : The curly brackets are for Objects.

Upvotes: 1

Candido Marcano
Candido Marcano

Reputation: 1

Here you can find some info about your doubts: https://www.w3schools.com/js/js_datatypes.asp

Upvotes: 0

Thomas Fritsch
Thomas Fritsch

Reputation: 10127

[] is an empty array (i.e. with zero items).

{} is an empty object (i.e. with zero key-value pairs).

Upvotes: 6

Related Questions