【发布时间】:2016-08-25 03:04:21
【问题描述】:
我正在使用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
$
猜不出来!
是否有任何等效的方法可以在节点的 shell 环境中检查这样的对象?
【问题讨论】:
-
不带参数的
dir()怎么样,例如locals()和globals()? -
好的,在 REPL 中按两次 TAB 会做很多有趣的事情(也在空提示下)。当然,这是在交互式工作时,但
dir()也不是一个真正的程序实用程序。
标签: javascript node.js read-eval-print-loop