JavaScript Array Methods Part2 - JavaScript Tutorial 99

Published: 04 March 2022
on channel: ChidresTechTutorials
625
18

Notes for You:: JavaScript Array Methods Part2 - JavaScript Tutorial 99

JavaScript Array Methods unshift() and shift():

unshift() Method:
adds one or more elements to the beginning of the array
and returns the new length of the array

Syntax:
unshift(...args):number
where:
...args : indicates one or more elements
number: indicates the new length of the array


shift() Method:
removes the element at the beginning of the array
and returns that element

Syntax:
shift():*
where:
*: indicates the first element in the array


Example code:
var studNames = ["Ram","Ravi","Raju","Raghu","Gopal"];

document.write( studNames ); // Ram, Ravi, Raju, Raghu, Gopal
document.write( "<br/>" );
document.write( studNames.length ); // 5
document.write( "<br/>" );
document.write( "<br/>" );

document.write(studNames.unshift("Hitesh")); // 6
document.write( "<br/>" );
document.write(studNames); // Hitesh, Ram, Ravi, Raju, Raghu, Gopal
document.write( "<br/>" );
document.write( "<br/>" );

document.write(studNames.shift()); // Hitesh
document.write( "<br/>" );
document.write(studNames); // Ram, Ravi, Raju, Raghu, Gopal
document.write( "<br/>" );

Note:
replace < with less-than symbol.
replace > with greater-than symbol.


=========================================

Follow the link for next video:
JavaScript Tutorial 100 - splice() Method | slice() Method | JavaScript Array Methods
   • JavaScript Array Methods Part3 - Java...  

Follow the link for previous video:
JavaScript Tutorial 98 - JavaScript Array Methods | push() Method | pop() Method
   • JavaScript Array Methods Part1 - Java...  

=========================================

JavaScript Tutorials Playlist:-
   • JavaScript Tutorials  

=========================================
Watch My Other Useful Tutorials:-

jQuery Tutorials Playlist:-
   • jQuery Tutorials  

jQuery UI Tutorials Playlist:-
   • jQuery UI Tutorials  

Bootstrap Tutorials Playlist:-
   • Bootstrap4 Tutorials  

=========================================

► Subscribe to our YouTube channel:
   / chidrestechtutorials  

► Visit our Website:
https://www.chidrestechtutorials.com

=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial


On this page of the site you can watch the video online JavaScript Array Methods Part2 - JavaScript Tutorial 99 with a duration of hours minute second in good quality, which was uploaded by the user ChidresTechTutorials 04 March 2022, share the link with friends and acquaintances, this video has already been watched 625 times on youtube and it was liked by 18 viewers. Enjoy your viewing!