Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Object JavaScript sample JavaScript with a bug
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