Inserts an array element at the beginning of an array
and shifts the positions of the existing elements to
make room.
arrayPrepend(array, value)
→ returns boolean
someArray.prepend(value)
Uses the arrayPrepend function to prepend a value to the beginning of an array and shifts the positions of the existing elements.
someArray = [3,2,1];
arrayPrepend(someArray, 4);
writeDump(someArray);
Expected Result: [4,3,2,1]
CF 11+ Lucee 4.5+ Invoking the prepend function on an array is the same as running arrayPrepend.
doctorArray = ['Eccleston','Tennant','Smith','Capaldi'];
doctorArray.prepend('Hurt');
writeDump(doctorArray);
Expected Result: ['Hurt','Eccleston','Tennant','Smith','Capaldi']
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.