I wonder the difference between two codes below in JavaScript, welcome answer.
Code 1:
function Add(a,b) {
return a + b;
}
Code 2:
function Add(a,b) {
return a + b;
};
I wonder the difference between two codes below in JavaScript, welcome answer.
Code 1:
function Add(a,b) {
return a + b;
}
Code 2:
function Add(a,b) {
return a + b;
};
The second code contains an empty statement. You can add as many as you want.
function Add(a,b) {
;;;;;
return a + b;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
There is no difference. The ;
in the second example just creates an empty statement there.
First one is the standard method
Second one is not recommended.. Use the first method
Further reading - Why should I use a semicolon after every function in javascript?