Skip to content

Instantly share code, notes, and snippets.

@bitfishxyz
Created February 3, 2019 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitfishxyz/9ae450cc58831f6c54a3914ebed263a2 to your computer and use it in GitHub Desktop.
Save bitfishxyz/9ae450cc58831f6c54a3914ebed263a2 to your computer and use it in GitHub Desktop.
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