Skip to content

Instantly share code, notes, and snippets.

View wicharek's full-sized avatar

Vitalii Ivanov wicharek

View GitHub Profile
@wicharek
wicharek / getAllClassMethods.js
Created March 21, 2018 14:21
JavaScript: get all method names of the provided object
const getAllClassMethods = (obj) => {
let keys = []
let topObject = obj
const onlyOriginalMethods = (p, i, arr) =>
typeof topObject[p] === 'function' && // only the methods
p !== 'constructor' && // not the constructor
(i === 0 || p !== arr[i - 1]) && // not overriding in this prototype
keys.indexOf(p) === -1 // not overridden in a child