Skip to content

Instantly share code, notes, and snippets.

@fogus
Forked from neektza/book_example.js
Created June 20, 2013 12:24
Show Gist options
  • Save fogus/5822272 to your computer and use it in GitHub Desktop.
Save fogus/5822272 to your computer and use it in GitHub Desktop.
// Section: "Prototype-based OO programming", 2nd example
var bFunc = function() { return this }
var b = { name: "b", fun: bFunc }
b.fun()
// => Object {name: "b", fun: function}
var obj = { name: "I'm an object", myself: function() { return this } }
obj.myself()
// => Object {name: "I'm an object", myself: function}
pseudoSelf = obj.myself
pseudoSelf()
// => Window {top: Window, window: Window, location: Location, external: Object, chrome: Object…}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment