Toggle logical NOT operator based on a boolean value I'm trying to think of a better way to write the below Javascript/NodeJS code without having to check the value of the boolean using an if statement. I know this can be accomplished with a ternary, but that would look ugly.

This is of course only an example, I'm sure there's a better way to write this; however I'm specifically wondering about this use-case.

var getNumbers = function(getNumbers) {
    return function(e) {
        if (getNumbers) {
            return !isNaN(e) ? e : null;
        } else {
            return isNaN(e) ? e : null;
        }
    };
};

var data = ['A', 'B', 'C', 'D', '1', '2', '3', '4'];

console.log(data.filter(getNumbers(true)));
console.log(data.filter(getNumbers(false)));


Output:

[ '1', '2', '3', '4' ]
[ 'A', 'B', 'C', 'D' ]
Using a function name as a variable name inside said function
This can be very confusing to someone reading your code(or you after having been away from your code for awhile)
Hither forth, getNumbers (the variable in the function) shall be referred to as showNumbers
XOR it baby
XOR is exactly what the current logic is doing anyway.
When showNumber is true invert other boolean value
//showNumber = true
T ^ showNumber == F
F ^ showNumber == T

Else leave as it was
//showNumber = false
T ^ showNumber == T
F ^ showNumber == F

var getNumbers = function(showNumbers) {
    return function(e) {
        return isNaN(e) ^ showNumbers ? e : null;
    };
};

Potential gotcha
Javascripts XOR(^) is bitwise NOT Logical