0

Today i'm facing a really strange behavior, check this out !

const person = [];
person.name = "Hello World"
console.log(person) // [name: "Hello World"]

That is crazy, I just pushed some key - value pair in a javascript array ? Can someone explain to me what just happened ? :)

Have a good day

J.doe
  • 115
  • 10
  • When I'm running that exact code on codesandbox.io my the output is just an empty array. What are you using to compile/run the code? – Puk May 28 '20 at 20:00
  • Just open the console(f12) and try it out :) – J.doe May 28 '20 at 20:14

0 Answers0