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 -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -