VOOZH about

URL: https://www.geeksforgeeks.org/javascript/underscore-js-_-extend-function/

⇱ Underscore.js _.extend() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Underscore.js _.extend() Function

Last Updated : 12 Jul, 2025

Underscore.js_.extend() function is used to create a copy of all of the properties of the source objects over the destination object and return the destination object. The nested arrays or objects will be copied by using reference, not duplicated.

Syntax:

_.extend(destination, *sources);

Parameters:

  • destination: This parameter holds the destination object file.
  • sources: This parameter holds the source object file.

Return Value:

It returns a copy of all of the properties of the source objects over the destination object and returns the destination object.

Example 1: In this example, we are using the Underscore.js _.extend() function.

Output:

👁 Image

Example 2: In this example, we are using the Underscore.js _.extend() function.

Output:

👁 Image
Comment