javascript shift() method
Translation results:
英[ʃɪft] 美[ʃɪft]
vt.& vi. change; shift gears; remove; get rid of
vt. Change clothes of..., change (clothes); sell , sell; [computer] displace (data)
vi. (car) shift gears; change clothes; muddle through; make a living for oneself
n. Move, transfer, convert; change, change, Transform, replace, replace, swap, make it easier, substitute; (for cars, etc.) shifting
Third person singular: shifts Plural: shifts Present participle: shifting Past tense: shifted Past participle: shifted
javascript shift() methodsyntax
How to use the shift() method?
The shift() method can delete the first element from the array and return the value of the first element. The shift() method will change the length of the array.
Function: Used to delete the first element of the array and return the value of the first element.
Syntax: arrayObject.shift()
Description: If the array is empty, then the shift() method will not perform any operation. Returns undefined value. Please note that this method does not create a new array, but directly modifies the original arrayObject.
Return: The value of the original first element of the array.
Note: This method will change the length of the array. To remove and return the last element of an array, use the pop() method.
javascript shift() methodexample
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script type="text/javascript"> var arr = new Array(3) arr[0] = "George" arr[1] = "John" arr[2] = "Thomas" document.write(arr + "<br />") document.write(arr.shift() + "<br />") document.write(arr) </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance
Popular Recommendations
- Bitcoin ETF Inflows Resume Amid Shift In Market Sentiment
- Bitcoin Price Jumps to $63,000 After US Federal Reserve Policy Shift
- Dogecoin (DOGE) Network Activity Spikes, Signaling a Potential Market Sentiment Shift
- Bitcoin: Analyzing the Shift from Short-term to Long-term Holders
- Dogecoin (DOGE) Price Prediction: RSI Shift Ignited Optimism, Can DOGE Break Higher?
- Whales Shift Focus to AI-Powered Crypto IntelMarkets (INTL) for Enhanced Gains