I need to create an object in dynamically add properties but keep the sequence of adding. An example of the object I want to get:
var obj = {
"0%": 1,
"5%": 1,
"05%": 1,
"6%": 1,
}
The values can be different, but it is important to keep the sequence: For example, I have an array:
var arr =[
{
"0%": 1,
},
{
"5%": 1,
},
{
"05%": 1,
},
{
"6%": 1,
}
]
How can I convert it to what I want?
I tried to do like this:
var obj: { [k: string]: any } = {};
obj["0%"] = 1
obj["**5%**"] = 1
obj["05%"] = 1
obj["6%"] = 1
but as a result I get:
var obj = {
"0%": 1,
"**05**%": 1,
"5%": 1,
"6%": 1,
}