I really don’t understand this if with NOT! operator

firstly here is my code :

const removeFromArray = function (...args) {
const array = args[0];
const newArray = [];
array.forEach((item) => {
    if (!args.includes(item)) {
return newArray;

The problem is this !args.includes(item), the NOT operator, it really makes no sense in my mind in this case… I tried to reformulate, rewrite but it doesn’t help.

The function is supposed to push every element into the array unless it is included in the function arguments (for example with arguments like this : removeFromArray([1, 2, 3], 2, 4)) but how the ‘unless’ work with this if condition ?

Can you light up my lantern please ?


It seems you kind of interpreting the “unless” as literal here and I see how this might be a little bit confusing at first.

Perhaps if it was rephrased, it might be less confusing: don’t push element into array unless it’s NOT including in the arguments. Or more literal to actual code: if item is NOT in the arguments, add it to the array