First of all you need to understand how splice works
array.splice(start[, deleteCount[, item1[, item2[, ...]]]])
it takes start(starting index from zero), number of elements to be deleted, and rest any arguments will be added at that starting index.
Now you are clear with splice, so let go step by step for clearer understanding of those statments.
The following statement
fruits.splice(...[2,0].concat(["Lemon", "Kiwi"]));
after concatenation becomes
fruits.splice(...[2,0,"Lemon", "Kiwi"]);
after spread it becomes
fruits.splice(2,0,"Lemon", "Kiwi");
then splice will take fruits from index 2 and delete nothing(as given zero) and add rest of the arguments ie., "Lemon" and "Kiwi"
So You get ["Banana", "Orange", "Lemon", "Kiwi", "Apple", "Mango"]
Where as in
fruits.splice(2,0,["Lemon", "Kiwi"]);
the splice will take fruits from index 2 and delete nothing(again as given zero) and add rest of the arguments i.e, "["Lemon", "Kiwi"]"
So you get ["Banana", "Orange", ["Lemon", "Kiwi"], "Apple", "Mango"]
I hope it helps.
spliceProperties from here lorenstewart.me/2017/01/22/… - Feras Al Sousfruitsafter each operation instead of loggingAandB. - Barmar