Class: ArrayExtension

ArrayExtension


new ArrayExtension()

Methods


addArrayAtBeginning(arrayToAdd)

Add array at the beginning of array
Parameters:
Name Type Description
arrayToAdd array array to add at the beginning

addAt(index, value)

Insert item at index
Parameters:
Name Type Description
index number
value *

clear()

Clear array by removing all items

contains(item)

Check if array contains item
Parameters:
Name Type Description
item * item to check
Returns:
has/hasn't
Type
boolean

each(callback, context)

Loop array and call calbback for each item
Parameters:
Name Type Description
callback function
context object | null scope of function

getIndexesByItem(item)

Get index of the item
Parameters:
Name Type Description
item *

last()

Return last item of array

removeItemsByIndex(index)

remove item from array by the index
Parameters:
Name Type Description
index number index of the item to remove

shuffle()

Shuffle array

swapItems(firstIndex, secondIndex)

Swap 2 items of the array using indexes
Parameters:
Name Type Description
firstIndex number index of first item
secondIndex number index of second item