3 回答
TA贡献2036条经验 获得超8个赞
TA贡献1921条经验 获得超9个赞
a.push(...b)
Array.concat.
var a = [1, 2, 3];a = a.concat([5, 4, 3]);
const a = [1, 2, 3];const b = [...a, 5, 4, 3];
TA贡献2016条经验 获得超9个赞
.apply
Array.prototype.extend = function (other_array) {
/* You should include a test to check whether other_array really is an array */
other_array.forEach(function(v) {this.push(v)}, this);}var a = [1,2,3];var b = [5,4,3];a.extend(b);
.apply
Array.push.applyArray.slice.apply.
forEach.apply
Array.prototype.extend = function (array) {
array.forEach(this.push, this);}Array.prototype.forEachforEach
添加回答
举报
