JS: check existence of a var that equals 0

var toMatch;
toMatch = 0;
if (toMatch === 0) { // or !== if you're checking for not zero
    document.write("no");
} else {
    document.write(toMatch);
}

toMatch === 0 will check for zero.

toMatch === undefined will check for undefined

the triple equals are strict comparison operators for this sort of scenario. See this blessed question: Difference between == and === in JavaScript

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)