Skip to content
Related Articles

Related Articles

Improve Article

Underscore.js _.dec() Method

  • Last Updated : 07 Aug, 2020
Geek Week

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

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :