Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var customer = {
firstName: "John",
lastName: "Doe",
greetCustomer: function(){
console.log("Hello again " + this.firstName + " " + this.lastName + "!");
},
whatIsMyObject: function() {
console.log(this);
},
address: {
askAddress: function(){
prompt("Dear " + this.firstName + ", please enter your address");
},
whatIsMyObject: function() {
console.log(this);
}
}
}
customer.address.askAddress(); // Prints "Dear undefined, please enter your address"
customer.address.whatIsMyObject(); // Prints the object "address" in the console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment