Skip to content

Instantly share code, notes, and snippets.

Created February 22, 2016 05:00
Show Gist options
  • Save anonymous/9218461d432f86c935cd to your computer and use it in GitHub Desktop.
Save anonymous/9218461d432f86c935cd to your computer and use it in GitHub Desktop.
<html></html>
<script id="jsbin-javascript">
var Person = function(firstName) {
this.firstName = firstName;
};
Person.prototype.sayHello = function() {
console.log("Hello, I'm " + this.firstName);
};
var person1 = new Person("Alice");
var person2 = new Person("Bob");
var helloFunction = person1.sayHello;
person1.sayHello();
person2.sayHello();
helloFunction();
console.log(helloFunction === person1.sayHello);
console.log(helloFunction === Person.prototype.sayHello);
helloFunction.call(person1);
</script>
<script id="jsbin-source-javascript" type="text/javascript">var Person = function(firstName) {
this.firstName = firstName;
};
Person.prototype.sayHello = function() {
console.log("Hello, I'm " + this.firstName);
};
var person1 = new Person("Alice");
var person2 = new Person("Bob");
var helloFunction = person1.sayHello;
person1.sayHello();
person2.sayHello();
helloFunction();
console.log(helloFunction === person1.sayHello);
console.log(helloFunction === Person.prototype.sayHello);
helloFunction.call(person1);</script>
var Person = function(firstName) {
this.firstName = firstName;
};
Person.prototype.sayHello = function() {
console.log("Hello, I'm " + this.firstName);
};
var person1 = new Person("Alice");
var person2 = new Person("Bob");
var helloFunction = person1.sayHello;
person1.sayHello();
person2.sayHello();
helloFunction();
console.log(helloFunction === person1.sayHello);
console.log(helloFunction === Person.prototype.sayHello);
helloFunction.call(person1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment