클래스 (Class)
function Person(name) {
this._name = name;
}
Person.prototype.getName = function() {
return this._name;
}
const person = new Person('JS');
console.log(person.getName());
class Person {
constructor(name) {
this._name = name;
}
getName() {
return this._name;
}
}
const person = new Person('JS');
console.log(person.getName());
Last updated