(a statement can be a declaration, a function call, any expression , for example, assignment of an expression), then you must add ;For example:
var i = 10;
fun(10);
i = j + 3 && 20;
You should use { }it if you want to make a block of statements in general when you define a function , and for if if switch-case , etc.
Example:
(1)
if(a = b){
fun(2);
a = a + b;
}
(2)
while(1){
statement-1;
statement-2;
}
Function(3):
function f(var){
statement-1;
statement-2;
}
Special Occasions:
You need ;after }in for the dict and function:
var foo = function() {
statement-1;
};
This value expresses the definition of function and assignment.
objects:
var obj = {
a : 1,
b: 2,
}; // not you uses both `;` and `}`
source
share