Parameter
        
            
                Last updated on 
                
                    Apr 27, 2021
                
            
            
        
        
    
Description
Removes the first element of an array and returns the element that is removed. This method removes the element at the first index and shifts the values at consecutive indexes down. If you use ArrayShift in an empty array, you get an exception.
Returns
The shifted element.
Syntax
ArrayShift(array)
Member function
array.shift()
History
ColdFusion (2021 release): Added this function.
Parameters
| 
                    
     | 
                
            
                
                    
     Required/Optional  | 
                
            
                
                    
     Description  | 
                
            
        
|---|---|---|
| 
                    
     array  | 
            
                
                
                    
     Required  | 
            
                
                
                    
     The array to update.  | 
            
        
    
           
        Note
    
    
    
     
     
    
        
            
    
    
If the array is empty, there is an exception.
Example
Example 1
<cfscript>
    arr=["Jan","Feb","Mar","Apr","May"]
    shiftedElement=ArrayShift(arr)
    WriteOutput(shiftedElement) // Returns Jan
</cfscript>
		
	
Example 2
<cfscript>
    arr=[{"id":101,"name":"John"},
         {"id":102,"name":"Paul"},
         {"id":103,"name":"George"}
        ]
    shifted=ArrayShift(arr)
    WriteDump(shifted)
</cfscript>
		
	
Output