10.07.2017 Views

javascript_tutorial

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Javascript<br />

<br />

<br />

var arr = [0, 1, 2, 3].reverse();<br />

document.write("Reversed array is : " + arr );<br />

<br />

<br />

<br />

Output<br />

Reversed array is : 3,2,1,0<br />

shift ()<br />

Javascript array shift() method removes the first element from an array and<br />

returns that element.<br />

Syntax<br />

Its syntax is as follows:<br />

array.shift();<br />

Return Value<br />

Returns the removed single value of the array.<br />

Example<br />

Try the following example.<br />

<br />

<br />

JavaScript Array shift Method<br />

<br />

<br />

<br />

var element = [105, 1, 2, 3].shift();<br />

document.write("Removed element is : " + element );<br />

<br />

<br />

211

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!