Friday, September 19, 2025
HomeLanguagesJavascriptLodash _.unsplatl() Method

Lodash _.unsplatl() Method

The Lodash _.unsplatl() method takes a function expecting an array as its first argument and returns a function that works identically, but takes a list of leading arguments. It is similar to the unsplat() method. It mimics the rest parameter syntax in ECMAScript 6.

Syntax:

_.unsplatl( function )

Parameters: This method accepts a single parameter as mentioned above and discussed below:

  • function: It is the original function that takes its first argument as an array.

Return Value: This method returns a function.

Note: To execute the below examples, you have to install the lodash-contrib library by using this command prompt and execute the following command.

npm install lodash-contrib

Example 1:

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
function g (arr, val) {
    return val+" : "+arr;
}
  
var gfgFunc = _.unsplatl(g);
  
console.log(gfgFunc(10, 20, 30, 40, "A"))


Output:

A : 10, 20, 30, 40

Example 2: 

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
function g (arr) {
    return arr;
}
  
var gfgFunc = _.unsplatl(g);
  
console.log(gfgFunc(1, 2, 3, 4))


Output:

[ 1, 2, 3, 4 ]

Example 3: 

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
function g (arr,val) {
    return arr.join(val);
}
  
var gfgFunc = _.unsplatl(g);
  
console.log(gfgFunc("neveropen", "Computer Science Portal for Geeks", " : "))


Output:

neveropen : Computer Science Portal for Geeks
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32301 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6666 POSTS0 COMMENTS
Nicole Veronica
11840 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11898 POSTS0 COMMENTS
Shaida Kate Naidoo
6781 POSTS0 COMMENTS
Ted Musemwa
7056 POSTS0 COMMENTS
Thapelo Manthata
6739 POSTS0 COMMENTS
Umr Jansen
6744 POSTS0 COMMENTS