Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Lodash _.noop() Method

  • Last Updated : 14 Sep, 2020

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

The Lodash _.noop() method is used to return “undefined” irrespective of the arguments passed to it.

Syntax: 

_.noop()

Parameters: This method can take optional parameters of any type.

Returns: This method returns undefined.

Example 1:

Javascript




// Requiring the lodash library  
const _ = require("lodash");              
  
// Use of _.noop() method 
let val = undefined; 
let val2 = _.noop(); 
  
if (val == val2) 
    console.log("val and val2 are equal"); 
else
    console.log(`val and val2 are not equal`);

Output:

val and val2 are equal

Example 2:

Javascript




// Requiring the lodash library  
const _ = require("lodash");    
  
// Use of _.noop() method 
let obj = new Object(_.noop()) 
console.log(`Object is ${obj.Object}`) 
    
// Use of _.noop() method  
let arr = new Array(_.noop()) 
console.log(`Array is ${arr[0]}`)

Output :

Object is undefined
Array is undefined
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!