To print all methods of an object, we can use Object.getOwnPropertyNames and check if the corresponding value is a function. The Object.getOwnPropertyNames() method returns an array of all properties (enumerable or not) found directly upon a given object. Here are some code snippets.
Print all methods of Array
var classobj = Array; console.log(Object.getOwnPropertyNames(classobj).filter(function (x) { return typeof classobj[x] === 'function' }));
[ 'isArray', 'from', 'of' ]
Env: node version v10.24.1
Print all methods of Array.prototype
var classobj = Array.prototype; console.log(Object.getOwnPropertyNames(classobj).filter(function (x) { return typeof classobj[x] === 'function' }));
[ 'constructor', 'concat', 'find', 'findIndex', 'pop', 'push', 'shift', 'unshift', 'slice', 'splice', 'includes', 'indexOf', 'keys', 'entries', 'forEach', 'filter', 'map', 'every', 'some', 'reduce', 'reduceRight', 'toString', 'toLocaleString', 'join', 'reverse', 'sort', 'lastIndexOf', 'copyWithin', 'fill', 'values' ]
Env: node version v10.24.1
Note that Array.prototype properties are different from Array properties.