This will alert “10″:
var num = num || 10;
alert(num);
But so will this:
num = 0;
var num = num || 10;
alert(num);
Watch out for the cases where num is “falsey“.
This will alert “10″:
var num = num || 10;
alert(num);
But so will this:
num = 0;
var num = num || 10;
alert(num);
Watch out for the cases where num is “falsey“.