contact
1:該方法不會改變原有的數組,因此要使用一個變量接收 contact
後的值數組
2:該方法接收的參數能夠是 object
,也能夠是字符串函數
示例代碼:spa
contact object
code
var f = function () { let arr = []; let info1 = ['kangkang']; let info2 = ['fancy']; arr = arr.concat(info1); arr = arr.concat(info2); console.log(arr); }();
contact string
對象
var fun = function () { let arr = []; let name1 = "kangkang"; let name2 = "fancy"; arr = arr.concat(name1); arr = arr.concat(name2); console.log(arr); }();
代碼示例:blog
var info = {"name":"fancy","age":18}; var {name,age} = info; console.log(name); console.log(age);
代碼示例:字符串
var info \= \["kangkang","fancy"\]; var \[name1,name2\] \= info; console.log(name1); console.log(name2);