JavaScript Array shift()

📔 : Java Script 🔗

JavaScript shift() function , Array में से first element remove करता है। और removed element को ही return करता है।

JavaScript Array shift() Syntax



  1. array | required : array variable , जिसमे से value remove करनी है।

  2. Return Value : removed element को ही return करता है।

अगर  Array empty है तो , undefined return होगा।

JavaScript Array shift() Example

File : js_array_shift.html

CopyFullscreenClose FullscreenRun
<!DOCTYPE html>
      var arr=['PHP', 'JavaScript', 'jQuery', 'Laravel']; 
      document.writeln("Removed Element : " +arr.shift() + "<br>");
      document.writeln("Remaining Elements : " + arr);
Removed Element : PHP
Remaining Elements : JavaScript,jQuery,Laravel

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook