Created
February 22, 2016 05:00
-
-
Save anonymous/9218461d432f86c935cd to your computer and use it in GitHub Desktop.
// source http://jsbin.com/kuruku
This file contains hidden or 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
<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> |
This file contains hidden or 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
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