Created
December 22, 2014 17:51
-
-
Save devdays/b45ac66a77a421ca3ac9 to your computer and use it in GitHub Desktop.
Object JavaScript sample JavaScript with a bug
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
function Greeter(greeting) { | |
this.greeting = greeting; | |
} | |
Greeter.prototype.greet = function() { | |
return "Hello " + this.greeting; | |
}; | |
var greeter = new Greeter( { | |
message: "world" | |
}); | |
var button = document.createElement('button'); | |
button.innerText= "Say Hello"; | |
button.onClick = function() { | |
alert(greeter.greet()); | |
}; | |
document.body.appendChild(button); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment