10.07.2017 Views

javascript_tutorial

Create successful ePaper yourself

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

Javascript<br />

toString ()<br />

Javascript array toString() method returns a string representing the source<br />

code of the specified array and its elements.<br />

Syntax<br />

Its syntax is as follows:<br />

array.toString( );<br />

Return Value<br />

Returns a string representing the array.<br />

Example<br />

Try the following example.<br />

<br />

<br />

JavaScript Array toString Method<br />

<br />

<br />

<br />

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

var str = arr.toString();<br />

document.write("Returned string is : " + str );<br />

<br />

<br />

<br />

Output<br />

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

unshift ()<br />

Javascript array unshift() method adds one or more elements to the beginning<br />

of an array and returns the new length of the array.<br />

218

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

Saved successfully!

Ooh no, something went wrong!