I am looking for a solution that dynamically creates object keys (are they spelled correctly?).
Arbitrary example, but it works in chrome and firefox
var weeks = {} for(var i = 0; i < 5; i++){ $.extend(weeks, {["week" + i] : (i * 2)} } //weeks = {"week0":0,"week1":2,"week2":4,"week3":6,"week4":8}
Or an alternative arbitrary example
var object = { ["a" + 50]: "value" }
The problem seems to be related to the [] operator, but I do not understand how and why this problem only occurs in IE. I did not test in previous versions of IE11, but I would assume that the problem persists there.
Since the problem seems to be related to the [] operator itself, creating my keys in a variable and then dragging this variable into my [] will not do anything to fix this problem, so I seem to have both ideas and keywords for google.
So, is there a way to dynamically create object keys in IE?
source share