Parentheses ():
Parentheses have multiple functions relating to functions and structures. They are used to contain a list of arguments passed to functions and control structures and they are used to group expressions to control the order of execution. Some functions have no arguments and in this case, the space between parentheses is blank.
Examples:
function(a, b, c, d)
// Defining a function.
while (true) or, for (var i = 0; i < 10; i++)
// Defining the condition in a Loop.
if(condition)
// Defining the condition in the statement.
Brackets []:
In JavaScript we can use square brackets to define an array myArray =[]
. Also we can use them if we need to get access into the Arrayvar cars = array[0] + array[1]
Curly Braces {}:
With Curly Braces we define the beginning and the end of functions blocks and statement blocks such as the for() and if()
structures:
for (i = 0; i < cars.length; i++)
{text += cars[i] + "";}
if (cars) {code to execute when cars is true }
, or while (cars) { loop here }
or function f() { function here }
.
Single Quotes '' & Double Quotes "" :
In Javascript we can use singles or double quotes to define a string literal like:
var person = "It's ok?";
var person = "Yes is all 'Good'";
//or we can write,
var person = 'Yes is all "Good"';