ecmascript 6 - Fastest property injection in JavaScript? -


i have array of property names = ['prop1', 'prop2',...].

and need inject them standard properties object obj, without specifying values, i.e. undefined.

what efficient/performant way that?

and make difference when creating obj properties somehow?

i expect fastest option simple for loop running backward 0:

let obj = {}; (let = array.length - 1; >= 0; --i) {     obj[array[i]] = undefined; } 

but unless you've run real-world performance problem, it's premature optimization.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -