javascript - Incrementing undefined object properties without performance penalty -


is there way increment both defined , undefined properties of plain js object without performance "penalty"?

var foo = {   counter: 0 };  (var i=10000; >= 0; i--) {    foo['counter']++;   foo['anyothercounter']++; // should work 'counter' without errors  } 

using conditionals (if statement or ternary operator) check if property defined recognized performance penalty.

bleeding edge es features welcome.

you don't around conditional (of kind) in loop if don't setup property before.

i've set testcase @ http://jsperf.com/incrementing-properties, it's not of penalty if don't coerce undefined number.

bleeding edge es features welcome

i don't think so, they're rather not as optimized. proxies yield 0 instead of undefined non-existing properties might idea, though.


Comments

Popular posts from this blog

.htaccess - htaccess convert request to clean url and add slash at the end of the url -

php - facebook and github login HWIOAuthBundle and FOSUserBundle in Symfony2.1 -

hadoop - Sqoop installation export and import from postgresql -