Skip to content

Variable cannot accessed from a closure function called from setTimeout. #10

Description

@jingwood

Variable cannot accessed from a closure function called from setTimeout.

Related to #1

function abc() {
  var b = 20;
  
  return (function(){
    setTimeout(_ => console.log("b = " + b), 1000);
  })();
}

abc();

Current result

b = undefined

Expected result

b = 20

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions