-
-
Notifications
You must be signed in to change notification settings - Fork 16
.push
This method can be used two similar ways based on context:
🔹 𝙉𝙀𝙒 𝙆𝙀𝙔
localDataStorage.push( arrayKeyName, value1 [, value2 ...] )
This method stores value(s) under arrayKeyName, creating a new key if necessary, where the key prefix is prepended to arrayKeyName. As a shortcut for set, this automatically creates a new Array Key.
🔹 𝙀𝙓𝙄𝙎𝙏𝙄𝙉𝙂 𝙆𝙀𝙔
localDataStorage.push( arrayKeyName, value [, index] )
This is also used to place value onto an existing arrayKeyName, optionally at the index position, as a non-destructive insert. When index is omitted, the element is appended to the Array Key by default. When specified, the index is automatically corrected to prevent sparse arrays.
EXAMPLES:
Create and initialize a new Array Key by supplying discrete values:
● localData.push( 'nicknames', 'Mac', 'Will', 'Bill', 'Tom' ); --> ['Mac', 'Will', 'Bill', 'Tom']
Alternatively, create and initialize a new Array Key by supplying a single array value:
● localData.push( 'nicknames', ['Mac', 'Will', 'Bill', 'Tom'] );
Push a value onto an existing Array Key:
● localData.push( 'nicknames', 'Todd' ); --> ['Mac', 'Will', 'Bill', 'Tom', 'Todd']
Insert a value into the second position:
● localData.push( 'nicknames', 'Kay', 2 ); --> ['Mac', 'Kay', 'Will', 'Bill', 'Tom', 'Todd']
The value of the updated arrayKeyName is returned when this method executes.
When data must be added and deleted at the same time, use poke.
🌐 This method may fire an event allowing you to monitor the key change.
✨ The complement to this is pull.
📝 NOTE: This method is specific to Array Keys and will fail if used on any other key type. Multiple values can be set only when making a new key. Inserting values onto an existing key must be done one at a time. Array Keys use one-based array indices.
Array Keys:
push / pull, pullall poke contains where
Broadcasting:
broadcast
Data Transfer:
import / export
Duplicates:
countdupes, showdupes, listdupes
Internals:
cancrunch crunch / uncrunch
shufflestring / unshufflestring
Management:
keys
Memory Consumption:
Memory Quota:
showquota
Query:
haskey, hasval, hastype
setscramblekey / getscramblekey
Type Check:
isarray isbigint isboolean iscrunch
isdate isfloat isinteger isnull
Utility:
chopget copy softset rename
_set / _get _clear _key _remove
Management:
_keys
Type Check:
_isarray _isbigint _isboolean _iscrunch