Last Updated : 15 Jul, 2025
Lodash _.without method creates a new array in a filtered form that is there are values to exclude and give new values as output.
Note:It is dissimilar to the _.pull() method, this method returns a new array.
Syntax:_.without(array, [values]);Parameters:
Example 1: In this example, we are removing the given value from the given array and printing the results in the console.
javascript
// Requiring the lodash library
const _ = require("lodash");
// Original array
let w = _.without([3.2, 5.2,
5.2, 1.2], 5.2, 3.2);
// Use of _.without() method
// Printing the output
console.log(w);
Output:
[ 1.2 ]
Example 2: In this example, we are removing the given value from the given array and printing the results in the console.
javascript
// Requiring the lodash library
const _ = require("lodash");
// Original array
let w = _.without([3, 5, 5, 1], 1, 3);
let t = _.without([4, 7, 4, 8], 7, 4);
// Use of _.without() method
// Printing the output
console.log(w);
console.log(t);
Output:
[ 5, 5 ]
[ 8 ]
Example 3: In this example, we are removing the given value from the given array and printing the results in the console.
javascript
// Requiring the lodash library
const _ = require("lodash");
// Original array
let w = _.without(['a', 'b',
'c', 'b'], 'a', 'b');
let x = _.without(['C++', 'Java',
'Python', '.Net'], 'C++', 'Java');
// Use of _.without() method
// Printing the output
console.log(w);
console.log(x);
Output:
[ 'c' ]
[ 'Python', '.Net' ]
Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4