Open In App

Lodash _.stubTrue() Method

Last Updated : 03 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Lodash _.stubTrue() method is used to return a true value. It always returns true when it is called.

Syntax: 

_.stubTrue();

Parameters:

This method does not accept any single parameter. 

Return Value:

It returns a true value.

Example 1: In this example, this method is returning true and we are printing that result in the console.

Javascript




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


Output :

true

Example 2: In this example, this method is returning true in a for loop and we are printing that result in the console.

Javascript




// Requiring the lodash library 
const _ = require("lodash");
 
for (let i = 0; i < 10; i++) {
    // Printing the output 
    console.log(_.stubTrue());
}


Output :

true
true
true
true
true
true
true
true
true
true

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads