Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 22, 2014 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/b45ac66a77a421ca3ac9 to your computer and use it in GitHub Desktop.
Save devdays/b45ac66a77a421ca3ac9 to your computer and use it in GitHub Desktop.
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