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

This function is valid in v2.14.2 to v2.24.2. This function has been downloaded 40 times.


{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|Function} keys
If this is an array it must be the keys of the subject to be copied to the new object. If this is a function it will be called for each key/value pair (receiving the key as argument 1 and the value as argument 2) and whenever the return value is true-ish the key/value pair will 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.


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 Functions

This function directly requires the following functions which are included automatically:

  • entries()
    Gets an array of pairs (array of length 2) indicating all of the keys and values within a given array or object.
  • 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.