Skip to content

Instantly share code, notes, and snippets.

@rbonvall
Created June 28, 2013 06:19
Show Gist options
  • Select an option

  • Save rbonvall/5882819 to your computer and use it in GitHub Desktop.

Select an option

Save rbonvall/5882819 to your computer and use it in GitHub Desktop.
Incorrect example from the section on Prototype-based object-oriented programming, from @fogus's Functional JavaScript.
var a = {
name: 'a',
fun: function () { return this; }
};
var bFunc = function () { return this; };
var b = {
name: 'b',
fun: bFunc
};
console.log(a.fun());
// Book: => {name: 'a', fun: ...}
// Node: => {name: 'a', fun: ...}
console.log(b.fun());
// Book: => some global object, probably Window
// Node: => {name: 'b', fun: ...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment