Object.values >= 0.1.0

Purpose

Get an array of the object values

Description

`Object.values` has now (2017) been implemented in multiple browsers. That new implementation is more limited than this version and is twice as slow, even.

Since using Protoblast's `Object.values` method with only 1 parameter gives the same output as the native implementation, we're leaving it in.

Syntax

Object.values ( ObjectobjArraykeysBooleaninclude_prototype= false );

Parameters

obj

The object to get the values of

keys

The property names we want to limit the result to

include_prototype

Whether to also include values of the prototype

Return values

Array

Examples

Just get all the values

var obj = {
    a: 1,
    b: 2,
    c: 3,
    d: 4,
    e: 5
};

Object.values(obj);
>>> [1, 2, 3, 4, 5];

Get only the given keys

var obj = {
    a: 1,
    b: 2,
    c: 3,
    d: 4,
    e: 5
};

Object.values(obj, ['a', 'c', 'e']);
>>> [1, 3, 5];

Comments