+ 2
Javascript - Adding arrays
I understand sum is [1, 23, 4], but why length is 6? var nums1 = [1,2]; var nums2 = [3,4]; var set = nums1 + nums2; console.log(set.length); console.log(set);
2 Respostas
+ 6
the sum of array is a string data type.
[1,2]+[3,4]==="1,23,4"
//true
I hope this will help you to understand.
+ 3
the length is 6 because it sees the commas as part of the string.