Is there a nice way to convert Math
object into "real" javascript object?
I want to use Object.keys
on Math
object. Is that possible to not hardcode it all the way down?
Is there a nice way to convert Math
object into "real" javascript object?
I want to use Object.keys
on Math
object. Is that possible to not hardcode it all the way down?
The properties of Math
are not enumerable, so Object.keys(Math)
returns an empty array.
However, you can use
Object.getOwnPropertyNames(Math)
It will produce something like
["toSource","abs","acos","asin","atan","atan2","ceil","clz32","cos","exp","floor","imul","fround","log","max","min","pow","random","round","sin","sqrt","tan","log10","log2","log1p","expm1","cosh","sinh","tanh","acosh","asinh","atanh","hypot","trunc","sign","cbrt","E","LOG2E","LOG10E","LN2","LN10","PI","SQRT2","SQRT1_2"]