JS defineProperty and prototype
问题 As you know we can define getters and setters in JS using defineProperty() . I've been stuck when trying to extend my class using defineProperty() . Here is an example code: I have an array of fields which must be added to a object fields = ["id", "name", "last_login"] Also I have a class which will be modified var User = (function(){ // constructor function User(id, name){ this.id = id this.name = name } return User; })(); And a function which will add fields to the class using