10.02.2018 Views

js_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Javascript<br />

Syntax<br />

Its syntax is as follows:<br />

array.unshift( element1, ..., elementN );<br />

Parameter Details<br />

element1, ..., elementN : The elements to add to the front of the array.<br />

Return Value<br />

Returns the length of the new array. It returns undefined in IE browser.<br />

Example<br />

Try the following example.<br />

<br />

<br />

JavaScript Array unshift Method<br />

<br />

<br />

<br />

var arr = new Array("orange", "mango", "banana", "sugar");<br />

var length = arr.unshift("water");<br />

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

document.write(" Length of the array is : " + length );<br />

<br />

<br />

<br />

Output<br />

Returned array is : water,orange,mango,banana,sugar<br />

Length of the array is : 5<br />

219

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

Saved successfully!

Ooh no, something went wrong!