class Dog {
constructor(name) {
this._name = name;
this._behavior = 0;
}
get name() {
return this._name;
}
get behavior() {
return this._behavior;
}
incrementBehavior() {
this._behavior ++;
}
}
const halley = new Dog('Halley');
console.log(halley.name);
console.log(halley.behavior);
halley.incrementBehavior();
console.log(halley.name);
console.log(halley.behavior);
'JAVASCRIPT' 카테고리의 다른 글
배열 (0) | 2020.10.22 |
---|---|
함수 (0) | 2020.10.21 |
code academy object 예제4 (0) | 2020.07.09 |
code academy object 예제3 (0) | 2020.07.09 |
code academy object 예제2 (0) | 2020.07.09 |