Reputation: 123
There being a ' ; ' after one and not the other. I was wondering if there was a difference or additional functionality between these 2 if statements?
func(x){ // with a ; at end
if (false){
throw new Error('blah');
};
}
func(x){ // without a ; at end
if (false){
throw new Error('blah');
}
}
Upvotes: 1
Views: 51
Reputation: 588
There is no differences or additional functionality between the 2 statements
Semicolons are optional in javascript, the interpreter will insert a semicolon at the end of a statement if needed.
In other programming languages like C, the semicolon denotes to the compiler the end of one instruction and the beginning of the next.
Upvotes: 0
Reputation: 782498
There's no difference.
You don't need a ;
after a statement block. If you add one, it's just terminating an empty statement, which doesn't do anything.
The first version is probably a typo, it's not normal to put a ;
there.
Upvotes: 2