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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -