Skip to content

Instantly share code, notes, and snippets.

@koorchik
Created July 17, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koorchik/9c0fc5c3aaba649e2750 to your computer and use it in GitHub Desktop.
Save koorchik/9c0fc5c3aaba649e2750 to your computer and use it in GitHub Desktop.
Scope issue in javascript
var obj = { name: 'koorchik', age: 31 };
var funcs = {};
for (var prop in obj) {
funcs[prop] = function() { return obj[prop] };
}
console.log( funcs.name(), funcs.age() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment