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

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

ruby on rails - one-to-many through referance table -

python - Pygame screen.blit not working -