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

if (i in this &&<br />

fun.call(thisp, this[i], i, this))<br />

return true;<br />

}<br />

};<br />

return false;<br />

Example<br />

Try the following example.<br />

<br />

<br />

JavaScript Array some Method<br />

<br />

<br />

<br />

if (!Array.prototype.some)<br />

{<br />

Array.prototype.some = function(fun /*, thisp*/)<br />

{<br />

var len = this.length;<br />

if (typeof fun != "function")<br />

throw new TypeError();<br />

var thisp = arguments[1];<br />

for (var i = 0; i < len; i++)<br />

{<br />

if (i in this &&<br />

fun.call(thisp, this[i], i, this))<br />

return true;<br />

}<br />

214

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

Saved successfully!

Ooh no, something went wrong!