if (foo) {
// code to run if foo exists
}
results in Uncaught ReferenceError: foo is not defined
So how am i supposed to check if foo
exists?
if (foo) {
// code to run if foo exists
}
results in Uncaught ReferenceError: foo is not defined
So how am i supposed to check if foo
exists?
There's several ways - one is
if(typeof foo !== 'undefined'){
// your code here.
}