jQuery.map( array | jquery array
Description:Translateallitemsinanarrayorobjecttonewarrayofitems.IfyouwishtoprocessajQueryobject—forexample,$(div).map(callback);—use.map()[1]instead.The$.map()methodappliesafunctiontoeachiteminanarrayorobjectandmapstheresultsintoanewarray.PriortojQuery1.6,$.map()supportstraversingarraysandarray-likeobjectsonly.AsofjQuery1.6italsotraversesobjects.Array-likeobjects—thosewitha.lengthpropertyandavalueonthe.length-1index—maybepassedto$.map().1234567varfakeArray={"length":2,0:"Addy",1:"Subtracty"}...
Description: Translate all items in an array or object to new array of items.
If you wish to process a jQuery object — for example, $(div).map( callback ); — use .map()[1] instead.
The $.map() method applies a function to each item in an array or object and maps the results into a new array. Prior to jQuery 1.6, $.map() supports traversing arrays and array-like objects only. As of jQuery 1.6 it also traverses objects.
Array-like objects — those with a .length property and a value on the .length - 1 index — may be passed to $.map().
1
2
3
4
5
6
7
var fakeArray = { "length": 2, 0: "Addy", 1: "Subtracty" };
$.map( realArray, function( val, i ) {
The translation function that is provided to this method is called for each top-level element in the array or ob...