// PROTOTYPE WAY
function Person (props) {
this.name = props.name
this.age = props.age
}
Person.prototype.say = function (word) {
console.log(`${this.name}: ${word}`)
}
// ES6 WAY
class Person {
constructor({ name, age }) {
this.name = name
this.age = age
}
say(word) {
console.log(`${this.name}: ${word}`)
}
}
var person = new Person({ name: 'Daiki', age: 22 })
person.say('hello!')