The _.extendOwn()
function in Underscore.js is a utility function that is used to copy all enumerable properties of one or more source objects to a destination object, and returns the destination object.
To use _.extendOwn()
, you need to load the Underscore.js library in your HTML file, like this:
38 chars2 lines
Or you can install it via NPM by running:
index.tsx23 chars2 lines
The basic syntax for using _.extendOwn()
is as follows:
index.tsx35 chars2 lines
Here is an example of usage:
index.tsx207 chars14 lines
In this example, the _.extendOwn()
function copies the age
property from the source
object to the destination
object, and adds the new occupation
property to the destination
object. The resulting object is { name: 'John', age: 35, occupation: 'Developer' }
gistlibby LogSnag