I am using jQuery in my web application. I want to use arrays, but I am not able to find out functions for arrays (add, remove or append elements in array) in jQuery. Is there any link related to jQuery array functions which will explain the jQuery array functions?
Have a look at
https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Array
for documentation on JavaScript Arrays. |
|||||
|
jQuery has very limited array functions since JavaScript has most of them itself. But here are the ones they have: Utilities - jQuery API. |
||||
|
An easy way to get the max and min value in an array is as follows. This has been explained at get max & min values in array
|
|||
|
The Visual jQuery site has some great examples of jQuery's array functionality. (Click "Utilities" on the left-hand tab, and then "Array and Object operations".) |
||||
|
There's a plugin for jQuery called 'rich array' discussed in Rich Array jQuery plugin . |
||||
|
Also there is a jquery plugin that adds some methods on an array. http://www.learningjquery.com/2009/02/implementing-prototypes-array-methods-in-jquery This plugin implements Prototypes lib array methods such as
and more |
|||
|
You can use underscore.js. It really makes things simple. For example removing elements from array you need to do -
and the result will be [1,3]. It reduces the code that you write using grep etc in jquery. |
|||
|
eq()
method and have a.length
property -- but most of the standard JavaScript array methods will not work on jQuery objects. – Blazemonger Sep 17 '11 at 20:14