10.02.2018 Views

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

var index = [12, 5, 8, 130, 44].lastIndexOf(8);<br />

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

var index = [12, 5, 8, 130, 44, 5].lastIndexOf(5);<br />

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

<br />

<br />

<br />

Output<br />

index is : 2<br />

index is : 5<br />

map ()<br />

Javascript array map() method creates a new array with the results of calling a<br />

provided function on every element in this array.<br />

Syntax<br />

Its syntax is as follows:<br />

array.map(callback[, thisObject]);<br />

Parameter Details<br />

<br />

callback : Function that produces an element of the new Array from an<br />

element of the current one.<br />

<br />

thisObject : Object to use as this when executing callback.<br />

Return Value<br />

Returns the created array.<br />

Compatibility<br />

198

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

Saved successfully!

Ooh no, something went wrong!