Javascript 对象与 JScript 字典

发布于 2024-07-23 18:15:36 字数 361 浏览 7 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

聆听风音 2024-07-30 18:15:37

从该文档看来,使用字典查找速度更快; 但是插入速度较慢。

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

别再吹冷风 2024-07-30 18:15:37

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...

染年凉城似染瑾 2024-07-30 18:15:37

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文