查看Node.js String.prototype的方法? [英] View methods of Node.js String.prototype?

查看:176
本文介绍了查看Node.js String.prototype的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Node.js REPL中,如果键入 String.prototype ,则空对象: {} 是回。但是,如果您在Chrome JavaScript控制台中输入它,则会返回一个包含预期函数名称和函数的对象。

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.

为什么Node.js不会出现此行为?如何在Node.js中访问本机String函数?

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

推荐答案

根据FreeNode /#node.js上的IRC用户

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


BennyLava:Object.getOwnPropertyNames(String.prototype)

BennyLava: Object.getOwnPropertyNames(String.prototype)

jmar777:因为在REPL中你基本上得到了对结果调用 toString()的结果,而chrome控制台有一些奇特的交互式对象显示

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:它们只是不可枚举

BennyLava: they're just not enumerable

所以答案是 Object.getOwnPropertyNames (String.prototype)

这篇关于查看Node.js String.prototype的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆