Skip to content

let assigment breaks typeof #33462

Closed
Closed
@mariorodriguespt

Description

@mariorodriguespt

What steps will reproduce the bug?

> let a = a || 2;
Uncaught ReferenceError: Cannot access 'a' before initialization
> typeof a !== 'undefined'
Uncaught ReferenceError: a is not defined
> typeof b !== 'undefined'
false

How often does it reproduce? Is there a required condition?

Every single time. If you use let to define a variable and in the assignment part you check if the same variable exists, you won't be able to use typeof after.

What is the expected behavior?

I would expect typeof should always work regardless of the variable a existing or not.

What do you see instead?

Uncaught ReferenceError: a is not defined

Additional information

This appear to be an issue in Chromium since it works as expected in Firefox.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions