Hi,
I have an array that might be present in my .aspx page, if it is, I want to fire a javascript function.
I tried:
if(someArray)
blah(someArray);
but I get an error when I havent' defined someArray.
Hi,
I have an array that might be present in my .aspx page, if it is, I want to fire a javascript function.
I tried:
if(someArray)
blah(someArray);
but I get an error when I havent' defined someArray.
if(typeof someArray !== 'undefined') {
blah(someArray);
}
You should probably be pre-defining the array as null and check to see if it resolves, rather than sometimes available.
Array someArray = null;
// this is where you'll populate or replace someArray
// if you don't, someArray simply remains empty
if (someArray)
{
...
}
var a = [];
var b = new Array();
alert(typeof a === "object" && a instanceof Array);
alert(typeof b === "object" && b instanceof Array);
alert(typeof c === "object" && c instanceof Array);