only()

Creates a new object with only the specified keys copied from the specified object to this new object.

This function is valid in v2.13.0 to v2.14.1. This function has been downloaded 0 times.

Parameters

{Object|undefined} opt_subject
If undefined this indicates that a partial function will be returned. Otherwise this is the object from which the properties should be copied.
{Array} keys
Keys of the subject to be copied to the new object.
{*=} opt_initial Optional, Default:{}
If given this is the object that will be returned and into which the properties will be copied.

Returns

{*}
If opt_subject was given opt_initial with the specified keys copied into it will be returned. Otherwise a partial function will be returned which will accept (1) the mandatory object from which to copy the properties and (2) the optional initial object that will be augmented and returned.

Required Function

This function directly requires the following function which is included automatically:

  • has()
    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.