-
I am a noobie at javascript and solidity. So learning everything was quite overwhelming for me at the start. But as we have moved along, I have found myself to be more comfortable in this space. I have started to look for the logic behind everything and have come a long way. But one place where I have been facing several issues is understanding how to use brackets. Like when is [] meant to be used, when {} is to be used and when () is to be used. So, it would be of great help if someone amongst you all could either explain it to me or provide me with some resources for me to understand which bracket to be used where? TL;DR: Help me understand how to use brackets in javascript. Please guide me to some resources... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@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. |
Beta Was this translation helpful? Give feedback.
@harshuo2 That's great! Coming to your question, {} is used for declaring an object,
[] is used for declaring an array; NOTE: it is a special form of an object that stores sequences of values.
() 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.