Tuesday, February 3, 2026
HomeLanguagesJavascriptUnderscore.js _.dec() Method

Underscore.js _.dec() Method

The _.dec() method returns the result by decrementing the given value by 1.

Syntax:

_.dec( value );

Parameters: This method takes a value and decrements them.

Return Value: This method returns the result by decrementing the given value by 1.

Note: This will not work in normal JavaScript because it requires the underscore.js contrib library to be installed. Underscore.js contrib library can be installed using npm install underscore-contrib –save.

Example 1: 

Javascript




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
var val = 33
var decrVal  = _.dec( val );
  
console.log("The Given value is :", val);
console.log("The Decrement of Given value is :", decrVal);


Output:

The Given value is : 33
The Decrement of Given value is : 32

Example 2:

Javascript




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
var val = 100
var decrVal  = _.dec( val );
  
console.log("The Given value is :", val);
console.log("The Decrement of Given value is :", decrVal);


Output:

The Given value is : 100
The Decrement of Given value is : 99
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!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32478 POSTS0 COMMENTS
Milvus
124 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11980 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12066 POSTS0 COMMENTS
Shaida Kate Naidoo
6987 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6935 POSTS0 COMMENTS
Umr Jansen
6919 POSTS0 COMMENTS