JavaScript Array Shift() method The shift() method removes the first item of an array. The shift() method changes the original array. The shift() method returns the shifted element. <! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta http-equiv = "X-UA-Compatible" content = "IE=edge" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title >Document</ title > </ head > < body > < h1 >JavaScript Array shift()</ h1 > < script > const fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ]; const delElem = fruits . shift (); console . log (delElem); console . log (fruits); </ script > </ body > </ html >
Comments
Post a Comment