Why the result of running the code?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 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 | 7 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
36,595 users