VOOZH about

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

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


  • Courses
  • Tutorials
  • Interview Prep

Underscore.js _.pairs() Function

Last Updated : 12 Jul, 2025

Underscore.js_.pairs() function is used to convert an object into an array of arrays that contain the [key, value] pairs of the object as elements.

Syntax:

_.pairs( object );

Parameters:

  • object: It contains the object element that holds the elements of key and value pair.

Return Value:

It returns the array of [key, value] pairs.

Example 1: The below code example implements the _.pairs() function of underscore.js practically.

Output:

👁 Image

Example 2: The below code example illustrates the another use of _.pairs() function of underscore.js.

Output:

👁 Image
Comment