Ezelia Posted August 2, 2013 Share Posted August 2, 2013 Hello all, Just wanted to share with you a little test I made, don't know if it's representative ... I allways thought that reading array fields was faster than reading object properties (maybe because of "for(;;)" is faster than "for in" syntax) .but I made a simple test with jsperf that gave me the opposite result : http://jsperf.com/object-prop-vs-array can you confirm that with real life examples ? Quote Link to comment Share on other sites More sharing options...
mgutz Posted August 2, 2013 Share Posted August 2, 2013 Whoa! I would have thought they would be the same, a['foo'] === a.foo I discovered issues with JsPerf in the past though when I was testing callbacks vs promises but that was async code. Quote Link to comment Share on other sites More sharing options...
Ezelia Posted August 2, 2013 Author Share Posted August 2, 2013 @mgutz actually it's not what's I'm saying here a['foo'] is the exact equivalent of a.foo I don't think you'll get any performance gaine here.what I did in the example is comparing array of values for example [30, 30, 40, 22] to an object holding each value in a property, example {x:30, y:30, z:40, p:22} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.