- Home /
checking for nulls in arrays
I have an array that's missing some values it may look like this myarray ,,,3,4,5
I want to check to see if myarray[0] is missing or not. How do I do that. I've tried creating an if statement with if(myarray[0]=="Null") or NULL or Null or Undefined but doesn't seem to work.
Thanks, Dan
Comment
What language are you using? What is the data type of your array?
Best Answer
Answer by Statement · Dec 15, 2011 at 08:16 PM
Try it without the citation marks.
if (myarray[0] == null)
Seems to work. The array is of integers but it works. Thanks.
Answer by jahroy · Dec 15, 2011 at 07:27 PM
What type of objects are the values in your array?
Certain types, like ints and floats, can never be null.
Also, if your type is int and it´s uninitialized it´s probably going to be set to 0.