Why the result of running the code?

0 like 0 dislike
3 views
let a = [1,2]; (function() { alert(a) })();


Long savvy, but could not understand why is output "1,2" and not [object Object] or something
by | 3 views

1 Answer

0 like 0 dislike
Because the variable a you have an array (Array), not an object (Object). And array the toString method is implemented in the following manner: toString
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,924 users