javascript nan to 0 code example
Example 1: how to replace nan with a value in js
if (isNaN(a)) a = 0;
Example 2: javascript change nan to 0
a = a || 0 //if "a" is false (NaN included), will return 0
Example 3: how to replace nan with a value in js
function getNum(val) {
val = +val || 0
return val;
}