ecmascript 6 - How to dynamically create static method in JavaScript? -


if have this:

class math {   static add(a, b) {     return + b   } } 

and want turn into:

class math {   static add(a, b) {     return + b   }   static subtract(a, b) {     return - b   } } 

is there way dynamically? eg.

class math {   static add(a, b) {     return a+b   } }  math.extend({   subtract: function(a, b) {      return a-b   } })  math.subtract(1,1) // 0 

static methods nothing methods on constructor. need assign methods math:

object.assign(math, {   subtract(a, b) {     return - b   } }); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -