Created
September 6, 2017 08:43
-
-
Save banyudu/4a5ac80acf6299192de50f81b9942365 to your computer and use it in GitHub Desktop.
Get method names from class in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User { | |
constructor() { | |
// do nothing | |
} | |
*createUser(params) { | |
// TODO: implement this function | |
} | |
*getUser(params) { | |
// TODO: implement this function | |
} | |
*updateUser(params) { | |
// TODO: implement this function | |
} | |
*deleteUser(params) { | |
// TODO: implement this function | |
} | |
} | |
const attrs = Object.getOwnPropertyNames(User.prototype); | |
for (const attr of attrs) { | |
const blacklist = ['constructor']; | |
const type = typeof User.prototype[attr]; | |
if (type === 'function') { | |
// do something | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment