Skip to content

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

@mklement0

Description

@mklement0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions