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

Error in chapter 7 (The Bad Parts): type(aVar?) doesn't work as described #60

Open
mklement0 opened this issue Oct 17, 2013 · 0 comments

Comments

@mklement0
Copy link

Chapter 7 says:
"
If you're checking to see if an variable has been defined, you'll still need to use typeof otherwise you'll get a ReferenceError.

if typeof aVar isnt "undefined"
    objectType = type(aVar)

Or more succinctly with the existential operator:

objectType = type(aVar?)

"

However, the two statements are NOT equivalent, because type(aVar?) will unconditionally return "boolean", because applying the existential operator to a variable always returns a Boolean.

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

No branches or pull requests

1 participant