If there is a new line, and we have a valid statement we use a semicolon after statement ?
What is a statement ?
x=x + "The number is " + i + "<br>";i++;
var varibale = 5;
var varibale = { };
var varibale = function(){};
alert("bar");
return{};
In some case semicolons are optional in JavaScript,
ECMAscript trys to be smart and will automatically insert semicolons if you didn't write, Therefore we can get unexpected resualt;
What do you think the output will be?
function foo(){
return // Bad!
{
name: "Jo"
};
}
var bar = foo();
alert (bar.name);
The output return :
undefined
Because when we run the function we get
return;
// Good
return {
name : "jo"
};











