Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/pluck/docs/types/index.d"

Index

Interfaces

Functions

Functions

Export assignment pluck

  • Extracts a property value from each element of an object array.

    Notes

    • The function skips null and undefined array elements.
    • Extracted values are not cloned.
    throws

    first argument must be an object array

    Parameters

    • arr: Array<any>

      source array

    • prop: PropertyName

      property to access

    • Optional options: Options

      function options

    Returns Array < any >

    destination array

    Example

    var arr = [
        { 'a': 1, 'b': 2 },
        { 'a': 0.5, 'b': 3 }
    ];
    
    var out = pluck( arr, 'a' );
    // returns [ 1, 0.5 ]

    Example

    var arr = [
        { 'a': 1, 'b': 2 },
        { 'a': 0.5, 'b': 3 }
    ];
    
    var out = pluck( arr, 'a', {'copy':false} );
    // returns [ 1, 0.5 ]
    
    var bool = ( arr[ 0 ] === out[ 0 ] );
    // returns true