Skip to content

Instantly share code, notes, and snippets.

@DamianMullins
Last active September 21, 2016 08:00
Show Gist options
  • Save DamianMullins/3c51c35c4417f5a3b81dae99b9c54f2e to your computer and use it in GitHub Desktop.
Save DamianMullins/3c51c35c4417f5a3b81dae99b9c54f2e to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
function foo (a) {
function bar () {
var a = 99;
}
function baz () {
a = 99;
}
bar(); // Calling this returns 1 as a was declared as a shadowed variable using `var`
baz() // Calling this returns 99 as a refers to the a variable in the scope of `foo()`, which is then redefined
console.log(a);
}
foo(1);
{
"name": "esnextbin-sketch",
"version": "0.0.0"
}
"use strict";
function foo(a) {
function bar() {
var a = 99;
}
function baz() {
a = 99;
}
bar(); // Calling this returns 1 as a was declared as a shadowed variable using `var`
baz(); // Calling this returns 99 as a refers to the a variable in the scope of `foo()`, which is then redefined
console.log(a);
}
foo(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment