Created
August 31, 2012 22:40
-
-
Save jpetto/3560291 to your computer and use it in GitHub Desktop.
JavaScript this demo #1
This file contains hidden or 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 user = { | |
greet: function() { | |
// this refers to the calling object - user | |
console.log("Hello there " + this.name + "!"); | |
} | |
}; | |
var name; | |
var get_name = function() { | |
// this refers to the calling object - window | |
this.name = prompt("What's your name?"); | |
}; | |
get_name(); | |
user.name = name; | |
user.greet(); | |
console.log(name); | |
console.log(user); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment