arcturo / library

A library of free eBooks we're working on

Home Page:http://arcturo.com/library/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mklement0 opened this issue · comments

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.