Skip to content

mentioning strict mode #264

@amid11

Description

@amid11

Function in if

let phrase = "Hello";

if (true) {
  let user = "John";

  function sayHi() {
    alert(`${phrase}, ${user}`);
  }
}

sayHi();

The result is an error.

The function sayHi is declared inside the if, so it only lives inside it. There is no sayHi outside.

When I execute the code I don't get any error unless in strict mode, I think it can be a good idea to remind others that in order to see the error we need to add `'use strict';' at the top of our code

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