Sunday, November 16, 2025
HomeLanguagesJavascriptLodash _.subtract() Method

Lodash _.subtract() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.subtract() method is used to subtract two numbers.

Syntax:

_.subtract(minuend, subtrahend)

Parameters: This method accepts two parameters as mentioned above and described below:

  • minuend: This parameter holds the first number in a subtraction.
  • subtrahend: This parameter holds the second number in a subtraction.

Return Value: This method returns the difference between two numbers.

Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library into the file.

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
    
// Use of _.subtract() method 
let gfg = _.subtract(50, 18); 
        
// Printing the output  
console.log(gfg);


Output:

32

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
    
// Use of _.subtract() method 
let gfg = _.subtract(87, -98); 
        
// Printing the output  
console.log(gfg);


Output:

185

Example 3:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
    
// Use of _.subtract() method 
let gfg = _.subtract(-126, -53); 
        
// Printing the output  
console.log(gfg);


Output:

-73
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
32402 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6768 POSTS0 COMMENTS
Nicole Veronica
11919 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11990 POSTS0 COMMENTS
Shaida Kate Naidoo
6897 POSTS0 COMMENTS
Ted Musemwa
7149 POSTS0 COMMENTS
Thapelo Manthata
6850 POSTS0 COMMENTS
Umr Jansen
6841 POSTS0 COMMENTS