ensureAt()

Is similar to setAt() but always ensures that the specified path will be added to the root object.

This function is valid in v2.17.0 to v2.17.1. This function has been downloaded 2 times.

Parameters

{*} root
The object under which to ensure the path.
{Array} path
An array of numbers or strings representing the path that must exist within root.
{*=} opt_value Optional, Default:undefined
If given this will be the value assigned to the specified path, otherwise undefined is assigned.

Returns

{*}
A reference to root.

Required Function

This function 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.