Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View methods of Node.js String.prototype?

In the Node.js REPL, if you type String.prototype, an empty object: {} is returned. But if you type it in the Chrome JavaScript console, an object is returned with the expected function names and functions.

Why doesn't Node.js exhibit this behavior? How can I access the native String functions in Node.js?

like image 461
JP Richardson Avatar asked Dec 31 '25 09:12

JP Richardson


1 Answers

According to the IRC users on FreeNode/#node.js

BennyLava: Object.getOwnPropertyNames(String.prototype)

jmar777: because in the REPL you basically get the result of calling toString() on the result, whereas the chrome console has some fancy interactive display of objects

BennyLava: they're just not enumerable

So the answer is Object.getOwnPropertyNames(String.prototype).

like image 72
JP Richardson Avatar answered Jan 02 '26 01:01

JP Richardson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!