javascript - ES6 . getter setter
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-18 10:45:31
0
1
403

class Person {

constructor (name, age) {
    this.name = name;
    this.age = age;
}
set name (name) {
    console.log("setter");
    this._name = name;
}
get name () {
    console.log("getter");
    return this._name;
}

// 加一个成员方法
sayName () {
    console.log(this.name);
}

}

The set get definition function here does not have the ES6 abbreviation of the previous set get. Why is the function here called by default during assignment

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
大家讲道理

Refer to this article/a/11...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!