Skip to content

Instantly share code, notes, and snippets.

@benjamn
Created August 3, 2015 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamn/05fd72808e6484e456f9 to your computer and use it in GitHub Desktop.
Save benjamn/05fd72808e6484e456f9 to your computer and use it in GitHub Desktop.
for-of loop compiled with Babel, both with and without "loose" mode
for (var _iterator = foo(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var x = _ref;
console.log(x);
}
var _temporalUndefined = {};
function _temporalAssertDefined(val, name, undef) { if (val === undef) { throw new ReferenceError(name + " is not defined - temporal dead zone"); } return true; }
for (var _iterator = foo(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var x = _temporalUndefined;
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
x = _ref;
console.log(_temporalAssertDefined(x, "x", _temporalUndefined) && x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment