JavaScript Utilities Library
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
- Created by: Aaron Gustafson
- Web Site: http://www.easy-designs.net/
- Posted: May 18, 2007
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.
Thanks, Simon. I missed that.
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[i] === 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[i] === needle) {[br /] return i;[br /] }[br /] }[br /] return false;[br /]}
Looking at the utility code emailed to me, the inArray function contains an operator ===. Is that correct?