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

};<br />

return false;<br />

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

}<br />

return (element >= 10);<br />

var retval = [2, 5, 8, 1, 4].some(isBigEnough);<br />

document.write("Returned value is : " + retval );<br />

var retval = [12, 5, 8, 1, 4].some(isBigEnough);<br />

document.write("Returned value is : " + retval );<br />

<br />

<br />

<br />

Output<br />

Returned value is : false<br />

Returned value is : true<br />

sort ()<br />

Javascript array sort() method sorts the elements of an array.<br />

Syntax<br />

Its syntax is as follows:<br />

array.sort( compareFunction );<br />

Parameter Details<br />

compareFunction: Specifies a function that defines the sort order. If omitted,<br />

the array is sorted lexicographically.<br />

215

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

Saved successfully!

Ooh no, something went wrong!