Pages
Categories
Archives
JsTweeterManiac
- #nodejs google plus fan page just crossed 1000 followers! http://t.co/IdbGqaXd 4 days ago
- #nodejs google plus fan page just crossed 800 followers http://t.co/IdbGqaXd ! 2 weeks ago
- hey @ryah {http://t.co/fdc8SCPR} you've done some cool stuff, I'm a fan via {http://t.co/2NPs9fNA} 2 weeks ago
- node.js makes programming fun again https://t.co/qgZwpOzL 3 weeks ago
- core #nodejs in #coffeescript? How about debugging this? http://t.co/iICMV30r 1 month ago
- 1999:Java - is for small projects,use C. 2005:Ruby - is for small projects,use Java. 2011:node.js - is for small projects, use Ruby for big 1 month ago
- >npm xmas 1 month ago
- WebStorm 3 officially out. With #nodejs and #coffeescriptsupport http://t.co/kCrF8Ba4 1 month ago
- Behold of #eval fanpage join #javascript #evil legions! https://t.co/9b2NotMs 1 month ago
- Position: fixed revisited http://t.co/jJ0fPsoy 1 month ago
-
RSS Links
-
Meta
Javascript performance. Array vs Object.
Big JavaScript application needs big storage. JS gives us 2 options Array and Object. I have tested following cases:
I have tested this in following browsers:
I want to point out that i am not comparing browsers. I am comparing two methods of storing data in JavaScript.
I have checked perfomance of following pices of code:
writing [ ]
// initialization var r=[]; //code to evaluate for (i=0;i<10000;i++){ this.r[i]=7; }writing {}
// initialization var r={}; //code to evaluate for (i=0;i<10000;i++){ this.r[i]=7; }writing [ ] randomly
// initialization var r=[]; //code to evaluate for (i=0;i<10000;i++){ this.r[Math.floor(Math.random(1000))]=7; }writing { } randomly
// initialization var r={}; //code to evaluate for (i=0;i<10000;i++){ this.r[Math.floor(Math.random(1000))]=7; }Here are results in ms:
Ok the result shows us that the perfomance of Array and Object as storage is almost equal.
So semantically i think it is wise to use array for unordered information and object for mapping.