In Python, for example, I can use
dir(str)
to find all the attributes and methods of the string data type.
Is there something similar in Javascript?
Just want additional info on JavaScript primitives. It's not an actual coding problem. Thanks.
let o = Object.getPrototypeOf('string') // equals to String.prototype
for (let k of Object.getOwnPropertyNames(o)) {
console.log(k, o[k])
}
same for all other primitives (number 123
, BigInt 123n
, symbol Symbol('symbolDesc')
)
Note however that some of them may be deprecated (mainnly string functions which wrap text.bold() == '<b>'+text+'</b>'
and alike)