Why does this happen

I was playing with with arrays and came across this code. My intentions were not to concatenate the two arrays. I just wanted to see what happens if you add two arrays with a + sign like two numbers. why is m a string ?

let x = [2, 3];
let y = [3, 2];

let m = x + y;


console.log(m);
console.log(m[1]);

type conversion
the two arrays has been forced to strings, when adding them together. And now m is a string

1 Like