Just opened a client\'s javascript file and the first lines are along the lines of this:
{
var s_account=\"blog\";
}
Which I don\'t get
It's called a block statement. It lets you group expressions. It's normally used with control structures like if
and while
, but can also be used on its own.
Since JavaScript doesn't have block scope, the code runs in the same scope (as if the {}
weren't there).
Example:
{
var s_account="blog";
}
console.log(s_account);
That works fine.