Comments in Javascript
Have a look at the Sandbox IDE for better understanding.
/* Example to show how to add comments an
how javascript engine or interpreter handles
the lines commented.
*/
//finding the factorial of given number. e.g: 5
function factorial(n) {
//if number is 1 or 0 then return 1
if (n === 0 || n === 1) return 1;
//else return n*factorial(n-1)
return Number(n * factorial(n - 1));
}
console.log(factorial(10));
/* Here it can be seen that i've added comments to explain
the lines of code.
The interpretter ignores the lines commented and
just moves to next line/block of code.
*/