prototypal inheritance
JavaScript
function person() {
this.printAge = function() {
console.log(this.age)
}
}
person.prototype.age = 20
var john = new person()
john.age = 33
john.printAge()
var mary = new person()
mary.printAge()
function person() {
this.printAge = function() {
console.log(this.age)
}
}
person.prototype.age = 20
var john = new person()
john.age = 33
john.printAge()
var mary = new person()
mary.printAge()