Returns a new array, from the start position up to the count of elements.
arraySlice(array, offset, length)
→ returns array
someArray.slice(offset, length)
array = [1, 2, 3, 4, 5, 6, 7, 8];
newArray = arraySlice(array, 2, 3);
writedump(newArray)
Expected Result: [2,3,4]
array = [1, 2, 3, 4, 5, 6, 7, 8];
newArray = arraySlice(array, 4);
writedump(newArray)
Expected Result: [4,5,6,7,8]
array = [1, 2, 3, 4, 5, 6, 7, 8];
newArray = arraySlice(array, -5, 3);
writedump(newArray)
Expected Result: [4,5,6]
CF 11+ calling the slice member function on an array.
array = [1, 2, 3, 4, 5, 6, 7, 8];
newArray = array.slice(2, 3);
writedump(newArray)
Expected Result: [2,3,4]
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.