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 />

Return Value<br />

Returns a sorted array.<br />

Example<br />

Try the following example.<br />

<br />

<br />

JavaScript Array sort Method<br />

<br />

<br />

<br />

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

var sorted = arr.sort();<br />

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

<br />

<br />

<br />

Output<br />

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

splice ()<br />

Javascript array splice() method changes the content of an array, adding new<br />

elements while removing old elements.<br />

Syntax<br />

Its syntax is as follows:<br />

array.splice(index, howMany, [element1][, ..., elementN]);<br />

Parameter Details<br />

<br />

index: Index at which to start changing the array.<br />

216

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

Saved successfully!

Ooh no, something went wrong!