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

var from = Number(arguments[1]) || 0;<br />

from = (from < 0)<br />

? Math.ceil(from)<br />

: Math.floor(from);<br />

if (from < 0)<br />

from += len;<br />

}<br />

for (; from < len; from++)<br />

{<br />

if (from in this &&<br />

this[from] === elt)<br />

return from;<br />

}<br />

return -1;<br />

};<br />

function printBr(element, index, array) {<br />

}<br />

document.write("[" + index + "] is " + element );<br />

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

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

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

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

<br />

<br />

<br />

Output<br />

index is : 2<br />

index is : -1<br />

193

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

Saved successfully!

Ooh no, something went wrong!