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

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

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