javascript - Node REPL 中 Python 的 dir() 的等价物?

标签 javascript node.js read-eval-print-loop

我正在使用 Uint8Array。我不习惯使用 Uint8Array

如果这是 Python:

>>> a = [1, 2, 3]
>>> dir(a)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>> help(a.pop)
< ... shows helpful function documentation ... >

但我使用的是 node shell:

$ node
> a = new Uint8Array([1, 2, 3])
Uint8Array { '0': 1, '1': 2, '2': 3 }
> a
Uint8Array { '0': 1, '1': 2, '2': 3 }
> a.pop
undefined
> help(a)
ReferenceError: help is not defined
    ...
> dir(a)
ReferenceError: dir is not defined
    ...    

嗯,StackOverflow 建议 Object.keys :

> Object.keys(a)  
[ '0', '1', '2' ]
> ???
... ???
... CTRL+D
$ 

猜不到!

在 Node 的 shell 环境中是否有任何等效的方法来检查这样的对象?

最佳答案

之后按 TAB 键。:

> a = new Uint8Array([1, 2, 3])
Uint8Array { '0': 1, '1': 2, '2': 3 }
> a. <<TAB>>
a.__defineGetter__      a.__defineSetter__      a.__lookupGetter__      a.__lookupSetter__      a.__proto__             a.constructor
a.hasOwnProperty        a.isPrototypeOf         a.propertyIsEnumerable  a.toLocaleString        a.toString              a.valueOf

a.BYTES_PER_ELEMENT     a.buffer                a.byteLength            a.byteOffset            a.copyWithin            a.entries
a.every                 a.fill                  a.filter                a.find                  a.findIndex             a.forEach
a.indexOf               a.join                  a.keys                  a.lastIndexOf           a.length                a.map
a.reduce                a.reduceRight           a.reverse               a.set                   a.slice                 a.some
a.sort                  a.subarray              a.values

> a.

关于javascript - Node REPL 中 Python 的 dir() 的等价物?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36947030/

相关文章:

javascript - 如果使用 jquery 再次删除已经删除的 div,则发出警报

javascript - 数据表 Ajax 重新加载在按钮单击时不起作用

javascript - 获得 "This app isn' t 验证“对于只涉及我的工作表的 Google 表格脚本

ios - 运行 react native ios 应用程序时找不到文件依赖项错误

node.js - 基于 REST 的 API 服务应使用哪种身份验证机制?

javascript - 如何启动可以访问 node.js 中的局部变量的 REPL?

javascript - 具有更新功能的 knockout 自定义选择 Binder

node.js - 如何使用monk连接多个MongoDB数据库?

lisp - Clisp REPL 错误输出 : how to find line number in file where error occurred?

javascript - Emacs 中的 Node REPL 打印我的输入