VAR is not defined #24

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@vitotafuni

$defined has to do with undefined variables.
Comparing a variable with null, instead of using typeof, make the browser to return a "VAR is not defined" error.

@kamicane
Member
kamicane commented Oct 6, 2010

This solves nothing. You get the error when you try to pass an undefined variable, not when it is compared to null.

$defined is there to check if the value of a defined variable is undefined or null.

@vitotafuni

sorry... so what's the right way to verify if a variable is undefined?
i have to use 'type of' directly in my code?

@kamicane
Member
kamicane commented Oct 6, 2010

yes, though I personally like to check this.varName. But that's just me.

@fabiomcosta
Member

yeah you do. You cant pass an undefined variable to any non-native-function. That's why $defined is not in 1.3.

@kamicane
Member
kamicane commented Oct 6, 2010

fabiomcosta: you cant pass an undefined variable anywhere, native or no native.

@vitotafuni

ok thank you both

kamicane: typeof is native and accept undefined vars ;-p

@fabiomcosta
Member

@kamicane yeah i thought some other native functions would accept too, but yeah looks like typeof is the ONLY function that accepts an undefined value.

@kamicane
Member
kamicane commented Oct 6, 2010

You're not passing it anywhere. It's not a function call.

@fabiomcosta
Member

typeof(a), function right?

@kamicane
Member
kamicane commented Oct 6, 2010

typeof is a special operator that can also be used with a function notation. It is not a function.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment