How does the spread syntax affect array splice How does the spread syntax affect array splice arrays arrays

How does the spread syntax affect array splice


First of all, Statement A & Statement B will generate different results.

In Statement A, you are inserting an array (["Lemon", "Kiwi"]) as an array element at position 2 while removing 0 items. So, you are inserting a string array in another string array at position 2.

var fruits = ["Banana", "Orange", "Apple", "Mango"];fruits.splice(2,0,["Lemon", "Kiwi"]);console.log(fruits);