I want to create a simple object.
Example: {house:'house, cat: 'cat', dog: 'dog', 45: 45 }
However javascript always takes the numbers in my array
Example: 45 - 45:45
and places it at the very top/front of my object.
Question 1: Why does this happen?
Question 2: How can I create my object with the items in order as presented in the array (yes I know that how they are placed within an object isn't important, since they all have keys) but please help.
let jakesLife = [
'house',
'cat',
'dog',
45
]
function x () {
let obj = {};
for (let i = 0; i < jakesLife.length; i++) {
obj[jakesLife[i]] = jakesLife[i];
}
return obj;
}
x()