To use the extendown
function from the Underscore library in TypeScript, first install the underscore library using npm:
index.ts23 chars2 lines
Then, import the library in your TypeScript file:
index.ts33 chars2 lines
Finally, you can use the extendown
function to recursively extend a destination object with any number of source objects:
index.ts260 chars20 lines
In the example above, the destination
object is extended with properties from source1
and source2
. The resulting object is logged to the console:
index.ts58 chars10 lines
Note that the extendown
function recursively extends objects, meaning that it handles nested objects as well.
gistlibby LogSnag