Skip to content

Instantly share code, notes, and snippets.

@DamianMullins
Last active September 21, 2016 09:11
Show Gist options
  • Save DamianMullins/1459bb9a259abd5f7bf61ae280baa9dd to your computer and use it in GitHub Desktop.
Save DamianMullins/1459bb9a259abd5f7bf61ae280baa9dd 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>
var foo = true;
// Fake block scope; bar belongs to the enclosing scope
if (foo) {
var bar = foo * 2;
console.log('bar inside if', bar);
}
console.log('bar outside if', bar);
// Block-scoping with let
{
console.log('bat before declaration', bat); // ReferenceError!
let bat = 2;
console.log('bat after declaration', bat); // ReferenceError!
}
if (foo) {
let baz = foo * 2;
console.log('baz inside if', baz);
}
console.log('baz outside if', baz);
{
"name": "esnextbin-sketch",
"version": "0.0.0"
}
'use strict';
var foo = true;
// Fake block scope; bar belongs to the enclosing scope
if (foo) {
var bar = foo * 2;
console.log('bar inside if', bar);
}
console.log('bar outside if', bar);
// Block-scoping with let
{
console.log('bat before declaration', bat); // ReferenceError!
var bat = 2;
console.log('bat after declaration', bat); // ReferenceError!
}
if (foo) {
var _baz = foo * 2;
console.log('baz inside if', _baz);
}
console.log('baz outside if', baz);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment