Adds the given item, or array of items, to the array.
Each item must be unique within the array.
The array is modified in-place and returned.
You can optionally specify a limit to the maximum size of the array. If the quantity of items being added will take the array length over this limit, it will stop adding once the limit is reached.
You can optionally specify a callback to be invoked for each item successfully added to the array.
name | type | arguments | description |
---|---|---|---|
array | array |
The array to be added to. |
|
item | any | Array.<any> |
The item, or array of items, to add to the array. Each item must be unique within the array. |
|
limit | number | <optional> |
Optional limit which caps the size of the array. |
callback | function | <optional> |
A callback to be invoked for each item successfully added to the array. |
context | object | <optional> |
The context in which the callback is invoked. |
The input array.