FB.Array
From Facebook Developer Wiki (FbDevWiki.com)
Array related helper methods useful with FB.Data.query.
Contents |
Methods
indexOf
Get index of item inside an array. Return's -1 if element is not found.
.indexOf(Array arr, Object item)
- parameter
- arr - Array to look through.
- item - Item to locate.
- return
- Index of item or -1 if element is not found.
merge
Merge items from source into target, but only if they dont exist. Returns the target array back.
.merge(Array target, Array source)
- parameter
- target - Target array.
- source - Source array.
- return
- Merged Array.
filter
Create an new array from the given array and a filter function.
.filter(Array arr, Function fn)
- parameter
- arr - Source array.
- fn - Filter callback function.
- return
- Filtered Array.
keys
Create an array from the keys in an object.
.keys(Object obj, Boolean proto)
Example: keys({'x': 2, 'y': 3'})
returns ['x', 'y']
- parameters
- obj - Source object.
- proto - Specify true to include inherited properties.
- return
- The Array of keys.
map
Create an array by performing transformation on the items in a source array.
.map(Array arr, Function transform)
- parameters
- arr - Source array.
- transform - Transformation function.
- return
- The transformed Array.
forEach
For looping through Arrays and Objects.
.forEach(Object item, Function fn, Boolean proto)
- parameters
- item - an Array or an Object
- fn - the callback function for iteration.
- proto - indicate if properties from the prototype should be included
- returns