Thursday, September 4, 2025
HomeLanguagesJavascriptLodash _.isPositive() Method

Lodash _.isPositive() Method

The Lodash _.isPositive() method checks whether the given value is Positive or not and returns the correspondingly boolean value.

Syntax:

_.isPositive(value);

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

  • value: Given value to be checked for a positive value.

Return Value: This method returns a Boolean value true if the given value is Positive, else false.

Note: This will not work in normal JavaScript because it requires the lodash.js contrib library to be installed. Lodash.js contrib library can be installed using the following command:

npm install lodash-contrib

Example 1:




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
// Checking for _.isPositive() method 
console.log("The Value is Positive : " + _.isPositive(20));


Output:

The Value is Positive : true

Example 2:




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
// Checking for _.isPositive() method 
console.log("The Value is Positive : " + _.isPositive(-1000));
  
console.log("The Value is Positive : " + _.isPositive("100"));


Output:

The Value is Positive : false
The Value is Positive : true

Example 3:




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
// Checking for _.isPositive() method 
console.log("The Value is Positive : " + _.isPositive(true));
  
console.log("The Value is Positive : " + _.isPositive([10, 20]));


Output:

The Value is Positive : true
The Value is Positive : false
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6629 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11858 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS