Created
August 11, 2016 23:28
-
-
Save anonymous/041125e695b7919869ebb1add3c7a0c2 to your computer and use it in GitHub Desktop.
prototype ex // source http://jsbin.com/jupuxoz
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>prototype ex</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
function person (name){ | |
this.name = name; | |
this.saysName = function(){ | |
console.log(this.name); | |
} | |
} | |
person.prototype.saysName = function () { | |
console.log(this.name); | |
} | |
var tom = new person('tom'); | |
var pres = new person('obama'); | |
tom.saysName(); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function person (name){ | |
this.name = name; | |
this.saysName = function(){ | |
console.log(this.name); | |
} | |
} | |
person.prototype.saysName = function () { | |
console.log(this.name); | |
} | |
var tom = new person('tom'); | |
var pres = new person('obama'); | |
tom.saysName();</script></body> | |
</html> |
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
function person (name){ | |
this.name = name; | |
this.saysName = function(){ | |
console.log(this.name); | |
} | |
} | |
person.prototype.saysName = function () { | |
console.log(this.name); | |
} | |
var tom = new person('tom'); | |
var pres = new person('obama'); | |
tom.saysName(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment