Created
February 3, 2019 06:19
-
-
Save bitfishxyz/9ae450cc58831f6c54a3914ebed263a2 to your computer and use it in GitHub Desktop.
This file contains 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
class PersonClass{ | |
constructor(name, age){ | |
this.name = name | |
this.age = age | |
} | |
getName(){ | |
return this.name | |
} | |
} | |
var p1 = new PersonClass('Bob', 18) | |
console.log(p1) | |
console.log(p1.getName()) | |
function PersonFunc(name, age){ | |
this.name = name | |
this.age = age | |
} | |
PersonFunc.prototype.getName = function(){ | |
return this.name | |
} | |
var p2 = new PersonFunc('Bob', 18) | |
console.log(p2) | |
console.log(p2.getName()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment