Is it possible to creat an object literal on the fly? Like this:
var arr = [ \'one\', \'two\', \'three\' ]; var literal = {}; for(var i=0;i
You can use for...of for the sake of simplicity:
for (const key of arr) { literal[key] = ""; }
Use this in your loop:
literal[arr[i]] = "";
for ( var i = 0, l = arr.length; i < l; ++i ) { literal[arr[i]] = "something"; }
I also took the liberty of optimising your loop :)