So i am trying to dig into a lot more Vanilla JS and i set up an object and an empty array and i pushed the object inside the array but when i console.log my array it returns the length only. What am i doing wrong or how can i see what is inside the array?
This is my sample code
let empty = []
let exp = {
2: 'Hey',
28: 'Yo',
9: 'Heyyyy!!',
6: 'Foo'
}
let newValue = empty.push(exp)
console.log(newValue)
Now if i do not use the newValue but do this instead it seems to work:-
let empty = []
let exp = {
2: 'Hey',
28: 'Yo',
9: 'Heyyyy!!',
6: 'Foo'
}
empty.push(exp)
console.log(empty)
Why does console.log(newValue) does not return the array and the object stored inside it? i thought that i should be able to assign values to a new variable. If someone can clear it, i sure will appreciate it.