ep.hashToArray()
Categories: Utilities
ep.hashToArray( object, [ type ] )
Plugin: ep.core
Description: Build an array from an object/hash.
-
ep.hashToArray( object, [ type ] )
version added: 6.11.0object An array through which to search.
type Type of array to get (keys/values) or both.
The ep.hashToArray()
method create an array from the givn object.
The type argument specify the type of the array to get, it can be 'k...' to get an array within the keys from the object, 'v.....' to get an array within the values from the object or empty to get an array within both arrays ( keys and values ).
-
Get an array of keys from th object.
Code:
var obj = { 'foo': 'bar', 'fo': 'ba', 'fruit': 'banana' }; ep.hashToArray( obj, 'k' );
Results:
[ 'foo', 'fo', 'fruit' ]
-
Get an array of values from th object.
Code:
var obj = { 'foo': 'bar', 'fo': 'ba', 'fruit': 'banana' }; ep.hashToArray( obj, 'v' );
Results:
[ 'bar', 'ba', 'banana' ]
-
Get an array of keys and values from th object.
Code:
var obj = { 'foo': 'bar', 'fo': 'ba', 'fruit': 'banana' }; ep.hashToArray( obj, 'v' );
Results:
[ [ 'foo', 'fo', 'fruit' ], [ 'bar', 'ba', 'banana' ] ]