Modifies an array by removing elements and adding new elements. It starts from the index, removes as many elements as specified by elementCountForRemoval, and puts the replacements starting from index position.
arraySplice(array, index[, elementCountForRemoval, replacements])
→ returns array
someArray.splice(index[, elementCountForRemoval, replacements])
months = ['Jan', 'March', 'April', 'June'];
item = ["Feb"];
arraySplice( months, 2, 0, item );
writedump(months);
Expected Result: ["Jan","Feb","March","April","June"]
months = ['Jan', 'March', 'April', 'June'];
item = ["Feb"];
arraySplice( months, 3, 2, item );
writedump(months);
Expected Result: ["Jan","March","Feb"]
months = ['Jan', 'March', 'April', 'June'];
item = ["Feb"];
arraySplice( months, -3, 0, item );
writedump(months);
Expected Result: ["Jan","Feb","March","April","June"]
months = ['Jan', 'March', 'April', 'June'];
item = ["Feb"];
arraySplice( months, 5, 0, item );
writedump(months);
Expected Result: ["Jan","March","April","June","Feb"]
months = ['Jan', 'March', 'April', 'June'];
item = ["Feb"];
months.splice( 2, 0, item );
writedump(months);
Expected Result: ["Jan","Feb","March","April","June"]
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.