Skip to content

Get all method names of an Object in JavaScript

Advertisements

The Object.getOwnPropertyNames() method returns a string array of all properties implemented directly upon a given object. We can use this method to return all methods in a given object.

Syntax

Object.getOwnPropertyNames(obj)

Example

Advertisements
console.log(Object.getOwnPropertyNames(Math))
(43)[
abs
acos
acosh
asin
asinh
atan
atanh
atan2
ceil
cbrt
expm1
clz32
cos
cosh
exp
floor
fround
hypot
imul
log
log1p
log2
log10
max
min
pow
random
round
sign
sin
sinh
sqrt
tan
tanh
trunc
E
LN10
LN2
LOG10E
LOG2E
PI
SQRT1_2
SQRT2
]
See also  Get total number of links from a HTML document using JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.