JavaScript Notation
Parentheses '()'
Parentheses have a number of uses within the JavaScript language including:
-
Executing a function. The parameters by which a function is executed may be included within the parentheses -- eg. var result = doSomething()
-
Maths Equations. Used in the same way they are used in Alegbra -- eg. b=(2+3)*4
-
Containing conditions and expressions for use in a variety of different types of loop -- eg. for(x=1)
-
Console.logging -- eg console.log()
Brackets '[]'
Brackets have quite specific uses in the JavaScript language
-
Make an array -- eg [hello, this, is, an, Array]
-
Locaiton indication within an array -- eg. document.getElementsByClassName[0]
Braces '{}'
These braces, also known as curly brackets are super important
-
Create objects which can be made up of any number of properties which can equally be made up of objects. Each object is surrounded by braces -- eg. var box = {obj}
-
Create a function. function makeFunction () {function}
Single Quotes '' vs Double Quotes ""
Quotation marks in JavaScript are used in opposition to one another in terms of their use. If one wants to create a string containing an apostrophe then one should use double quotes to make the string and vice versa. This helps to keep the intended visible mark easily accessible. It is, however, also possible to use a backslash before a quotation mark to make it visible within the string. The use of Quotation marks within JavaScript is relatively flexible and reflects the developers preference and depends mostly upon readability.