Parentheses vs Brackets [JavaScript]

javascript

#1

OK guys I'm pretty new to coding and I have to say what's the differences between parentheses and brackets? When are they supposed to be used?


#2

@thisguy_chris,
Do a google search
== discussions / opinions ==
javascript brackets vs parentheses site:stackoverflow.com
for instance
http://stackoverflow.com/questions/23225375/when-to-use-parentheses-brackets-and-curly-braces-in-javascript-and-jquery

== the Book ==
brackets parentheses braces site:developer.mozilla.org
or
brackets vs parentheses site:developer.mozilla.org


#3

Functions go between curly bracket: { }
Parenthesis () is used for conditions, console.log and more

I would say keep programming you will learn what goes where and how to use, "practice makes perfect!" and programming/coding requires practice


#4

you should refer to this 4 as

["brackets or square brackets"]
Brackets are used to index into an array.

("parentheses")
Parentheses are used for two purposes: (1) to control the order of operations in an expression, and (2) to supply parameters to a constructor or method.

{"braces or curly braces"} Braces are used to group statements and declarations.
The contents of a class or interface are enclosed in braces.
Method bodies and constructor bodies are enclosed in braces.
Braces are used to group the statements in an if statement, a loop, or other control structures.

< > are called angle brackets


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.