Whatever message this page gives is out now! Go check it out!
ArrayUnshift(array,object)array.unshift(item)Parameter | Required/Optional | Description |
array | Required | The array where an object is to be added. |
object | Required | The object to add at the beginning of the array. |
<cfscript>
arr=["Mar","Apr","May","Jun","Jul"]
unshifted=ArrayUnshift(arr,"Jan")
WriteOutput(unshifted) // Returns 6
</cfscript><cfscript>
arr=["Mar","Apr","May","Jun","Jul"]
// List as first element
unshifted=ArrayUnshift(arr,"Jan,Feb") // Returns 6
WriteOutput(unshifted)
</cfscript><cfscript>
arr=["Mar","Apr","May","Jun","Jul"]
// Array as first element
unshifted=ArrayUnshift(arr,["Jan,Feb"])
WriteOutput(unshifted) // Returns 6
</cfscript><cfscript>
arr=["Mar","Apr","May","Jun","Jul"]
// Struct as first element
elem={"id":101,"name":"John"}
unshifted=ArrayUnshift(arr,elem)
WriteOutput(unshifted) // Returns 6
</cfscript>