admin管理员组

文章数量:1391969

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.

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.

Share Improve this question edited Jan 22, 2014 at 3:28 GetFree asked Jun 4, 2009 at 14:13 GetFreeGetFree 42.7k20 gold badges86 silver badges106 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 2

It appears from this document that the lookup is quicker using Dictionary; however the inserts are slower.

https://web.archive/web/20181223064604/http://www.4guysfromrolla.:80/webtech/100800-1.2.shtml

Scripting.Dictionary is a COM/ActiveX ponent (can be used in any of MS scripting languages).

I wouldn't remend it because every time you access it, you're calling into the COM ponent, which is very slow.

But if you need its functionality, you can use it, but beware that it only works in IE...

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

本文标签: scriptingJavascript Object vs JScript DictionaryStack Overflow