JavaScript Utilities Library | JavaScriptSource

JavaScript Utilities Library

Aaron Gustafson May 18, 2007

General

This script provides functions for browsers which do not inherently support the entire JavaScript Core and supplies some useful functions PHP developers might wish they had access to.


Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: jsUtilitiesLib.js


Head

Paste this code into the HEAD section of your HTML document.


Leave a Response

(4 comments)

Yes, but check the new code. It has been corrected.

Lee Jun 5, 2007

Thanks, Simon. I missed that.

Lee Jun 5, 2007

From php, in_array should return true or false,[br /]so "return i" should be "return true"[br /][br /]function inArray(needle) {[br /] for (var i=0; i < this.length; i++) {[br /] if (this&#91;i&#93; === needle) {[br /] return true;[br /] }[br /] }[br /] return false;[br /]}[br /][br /]The function in the original post is actually the php function array_search[br /][br /]function arraySearch(needle) {[br /] for (var i=0; i < this.length; i++) {[br /] if (this&#91;i&#93; === needle) {[br /] return i;[br /] }[br /] }[br /] return false;[br /]}

Simon Tiplady May 21, 2007

Looking at the utility code emailed to me, the inArray function contains an operator ===. Is that correct?

SkewsMe May 20, 2007