When replacing an array in splice (index,n,data), what do you do if the replacement data is an array?

one of the recent problems encountered by the project is

splice(index,n,data)

will become an array to directly replace the selected data. Does Daniel know how to split the array replaced by the index position ? (there are other ways to implement it.)

Jan.29,2022

let list = [1, 2, 3, 7, 8];
list.splice(3, 1, ...[4, 5, 6, 7]);
console.log(list);

ES6

var list = [1, 2, 3, 7, 8];
list.splice.apply(list, [3, 1].concat([4, 5, 6, 7]));
console.log(list);

ES5


splice (index,n,.data)


splice (index,n,data) this statement itself is an array that replaces the index position and separates it separately. Your needs have been met.


ES6 array flattening
let list= [];
list=list.flat (Infinity);

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3beb7-43e01.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3beb7-43e01.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?