javascript - How to return a constructor argument value from a getter function in ES6 Classes -


example:

class person {   constructor(name) {    }    name() {     return /* “name” argument constructor */;       } } 

i name getter returns name value passed in constructor.

save argument instance property:

class person {   constructor(name) {     this.name_ = name;   }    name() {     return this.name_;   } } 

demo


Comments

Popular posts from this blog

mysql - How to unscape text from database in android studio -

php - Admin SDK -- get information about the group -

Making CSS Drop Down Menu 2 Columns -