Skip to content

Instantly share code, notes, and snippets.

Created August 11, 2016 23:28
Show Gist options
  • Save anonymous/041125e695b7919869ebb1add3c7a0c2 to your computer and use it in GitHub Desktop.
Save anonymous/041125e695b7919869ebb1add3c7a0c2 to your computer and use it in GitHub Desktop.
prototype ex // source http://jsbin.com/jupuxoz
<!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>
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