Created
August 8, 2011 15:44
-
-
Save johnmckerrell/1131992 to your computer and use it in GitHub Desktop.
Foo this demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var blah = 'foo'; | |
var myObject = {blah: 'I am myObject.foo'}; | |
var sayFoo = function() { | |
console.log(this['blah']); | |
}; | |
// give myObject a sayFoo property and have it point to sayFoo function | |
myObject.sayFoo = sayFoo; | |
myObject.sayFoo(); // logs 'I am myObject.foo' 12 | |
sayFoo(); // logs 'foo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment