天天看點

.concat()方法拼接

.concat() 拼接

至少2個

.concat()不會改變原數組,而是把元素加在後面,傳回一個新數組

let a = '1',
let b = '2',
let c = '3',

let x = a.concat(b);
console.log('x===',x);//'12'

let y = a.concat(b,c);
console.log('y===',x);//'123'

let z = a.concat();//傳回源資料
console.log('y===',x);//'1'