2017-07-03から1日間の記事一覧

【JavaScript】class構文で宣言したクラスのメソッド名を取得する

結論としては、prototypeに対して Object.getOwnPropertyNames()を使えばよい。 class Person { sayHello () { console.log('hello') } } let methods = Object.getOwnPropertyNames(Person.prototype) console.log(methods) // > [ 'constructor', 'sayHell…