let regex = /[a-z]+/;
regex.test('a'); // true
regex.test(''); // false
regex.test(null); // true
regex.test(undefined); // true
So based on this link, Is it a bug in Ecmascript - /\S/.test(null) returns true?, it looks like the null value is coerced to a string 'null'. WTF? Why on earth is this designed this way? I also can't find any documentation on this behavior. Is there a way to return false
for null/undefined values (without hardcoding in checks for 'null', etc.)?