Skip to content

Which bracket is to be used where? #726

Answered by 0xSanyam
harshuo2 asked this question in Q&A
Discussion options

You must be logged in to vote

@harshuo2 That's great! Coming to your question, {} is used for declaring an object,

var a = {name:"harsh", age:"18"};  // declaring objects
console.log(a.name); // accessing

[] is used for declaring an array; NOTE: it is a special form of an object that stores sequences of values.

var arr = []; // declaring an empty array
typeof arr // "object"

() is used for passing parameters in functions; () is also called a grouping operator.

Moreover, you may/should refer to this crash course video for javascript to help you following this course.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@waleedcj
Comment options

Answer selected by alymurtazamemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants