I'm trying to create a function that checks for something blank, empty, undefined, null etc.
But my difficulty is that I do not know all the forms of a string being "blank"
I created this function
function empty() {
var args = [].slice.call(arguments);
args.forEach(function(argument) {
if(!argument || 0 === argument.length || !argument || /^\s*$/.test(argument) || argument.length === 0 || !argument.trim()) {
return false;
}
});
}
The intention is to return false
so that I can simply check if my variables have some blank in this way if(!empty(var1, var2...)) {
But there are several ways, as I said, for example in my doubts:
If it is an array, how do you know if it is empty?
If it's a JSON how do you know if it's empty?
If it's only numbers, how can I tell if it's empty?
There are so many ways you have to check that I get lost ..
When I say empty I mean undefined, null, filled with only empty spaces etc.