Javascript 对象与 JScript 字典
Javascript 对象和 JScript 字典都是关联数组
obj = new Object ;
dic = new ActiveXObject("Scripting.Dictionary") ;
我的问题是...它们在效率(空间或时间)方面有什么区别吗??
就功能而言,我知道字典更好,因为它不仅仅允许标量类型作为键。 但抛开这一点,哪一个更好/更快?
编辑:
这适用于 Windows 脚本编写,不适用于 Web 开发。
编辑2:
我对查找效率特别感兴趣,因为我需要处理大集合。
Javascript Objects and JScript Dictionary are both associative Arrays
obj = new Object ;
dic = new ActiveXObject("Scripting.Dictionary") ;
My question is... Is there any difference between them in terms of efficiency (either space or time) ??
In terms of functionality, I know a Dictionary is better because it allows more than just scalar types as keys. But putting that aside, which one is better/faster?
EDIT:
This is for Windows scripting, not for web development.
EDIT2:
I'm particularly interested in the lookup efficiency, since I'll need to work with big collections.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从该文档看来,使用字典查找速度更快; 但是插入速度较慢。
https:// web.archive.org/web/20181223064604/http://www.4guysfromrolla.com:80/webtech/100800-1.2.shtml
It appears from this document that the lookup is quicker using Dictionary; however the inserts are slower.
https://web.archive.org/web/20181223064604/http://www.4guysfromrolla.com:80/webtech/100800-1.2.shtml
Scripting.Dictionary 是一个 COM/ActiveX 组件(可以在任何 MS 脚本语言中使用)。
我不推荐它,因为每次访问它时,都会调用 COM 组件,这非常慢。
但如果你需要它的功能,你可以使用它,但要注意它只适用于 IE...
Scripting.Dictionary is a COM/ActiveX component (can be used in any of MS scripting languages).
I wouldn't recommend it because every time you access it, you're calling into the COM component, which is very slow.
But if you need its functionality, you can use it, but beware that it only works in IE...
Javascript对象是执行引擎所固有的; Scripting.Dictionary 是一个 COM 对象,对每个操作执行互操作调用。
对于 javascript 中的任何内容,我倾向于使用引擎内类型,除非我非常需要基于具有良好相等语义的其他 COM 对象进行查找...
Javascript objects are inherent in the execution engine; Scripting.Dictionary is a COM object doing interop calls on every operation.
For anything in javascript, I would tend to prefer using the in-engine type unless I had a tremendous need for a lookup based on some other COM object with good equality semantics...