Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeof verification in "var?" verification? #2563

Closed
rafaelks opened this issue Sep 28, 2012 · 2 comments
Closed

Typeof verification in "var?" verification? #2563

rafaelks opened this issue Sep 28, 2012 · 2 comments

Comments

@rafaelks
Copy link

Hello,

Maybe I'm testing wrong, but this code:

foo(bar) if bar?

Is outputing it:

if (bar != null) {
  foo(bar);
}

I think that the correct output would be it:

if (typeof bar !== 'undefined' && bar !== null) {
  foo(bar);
}

Am I wrong?

In CoffeeScript.org, the example simulates exactly what I think, but the CoffeeScript "compiler" don't do it. (See Overview topic in CoffeeScript.org)

Thanks!

@vendethiel
Copy link
Collaborator

Could you please search in the issues ? This has been answered at least ten times.
Null check is only done if the variable isn't in the scope. Else it's useless

edit : FAQ => #2316 - see #1869 #1631 #2499 etc

@rafaelks
Copy link
Author

Thanks for you explanation and sorry by duplicated issue.

I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants