Quote:
Originally Posted by MrOmega
I found it strange though that null can equal -1 and 0.
|
null should never be -1, that was the
type of
null that was -1.
Quote:
Originally Posted by MrOmega
But setting actual variable to those can be confused with null, thus furthering the complication.
|
Yes, and this is fairly common, such as...
PHP Code:
function onCreated() {
temp.a = this.someFunction(0);
}
function someFunction(temp.i) {
if (temp.i == 1) {
return "yeay!";
}
}
This will result in
temp.a sometimes being set to an empty value, meaning it will have the same behavior as what I outlined in my post.
Quote:
Originally Posted by MrOmega
I prefer using the '!' (Not) before a var to check to see if it is indeed null. Null is full of lulz but it can be irritating cause of the flawz. z.z
|
Seems like a poor way to check if something is
null since it would also be true for anything which can be coerced to the integer
0.
I think using
x.type() == -1 is the best way to check if a variable doesn't exist (or if the return type of a function is
null/non-existent).