xam*_*mir -2 html javascript arrays html5 concatenation
在这个小提琴中,当使用
+运算符时,,跳过分隔符,而concat方法不会跳过,.
在javascript中,通常与+运算符和concat方法的串联是相同的.它也不适用于数组吗?
考虑一下:
[1, 2, 3] + [4, 5, 6] // "1,2,34,5,6"
[1, 2, 3].concat([4, 5, 6]) // [1, 2, 3, 4, 5, 6]
Run Code Online (Sandbox Code Playgroud)
在数组上使用plus concatenation运算符将使数组经历以下步骤:
[1, 2, 3] + [4, 5, 6]
[1, 2, 3].toString() + [4, 5, 6].toString()
"1,2,3" + "4,5,6"
"1,2,34,5,6"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
80 次 |
| 最近记录: |