Get an array of all JavaScript object methods.
const getMethods = obj => {
let properties = new Set();
let currentObj = obj;
do {
Object.getOwnPropertyNames(currentObj).map(item =>
properties.add(item)
);
} while ((currentObj = Object.getPrototypeOf(currentObj)));
return [...properties.keys()].filter(
item => typeof obj[item] === "function"
);
};
//
// Example usage:
//
getMethods("");
getMethods(new String("test"));
getMethods({});
getMethods(Date.prototype);