Instantly share code, notes, and snippets.

Embed
What would you like to do?
More issues with closures
// Google "mdn foreach"
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
function createLogger(i) {
console.log(item + ' ' + list[index]);
}
for (i = 0; i < list.length; i += 1) {
item = 'item' + list[i];
results.push(createLogger(i));
}
results.forEach(function (fn) {
fn();
});
(function(){ return this; }());
// http://stackoverflow.com/questions/3277182/how-to-get-the-global-object-in-javascript
(function () {
"use strict";
var globalish = (function(){ return this; }());
var global = new Function("return this;")();
console.log('g', global);
console.log('ish', !!globalish);
}());
Yes it is!
function bodily() {console.log("This is a bodily function");}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment