Created
October 20, 2016 15:39
-
-
Save zerobias/f7ec650ec29ebd26e2ee06144e61d5c1 to your computer and use it in GitHub Desktop.
How to filter really empty data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isEmpty = (a, b, c) => { | |
return ![a, b, c].join(""); | |
} | |
var isEmpty = (...rest) => { | |
return !rest.join(""); | |
} | |
isEmpty(void 0, [], null) // => true | |
isEmpty(void 0, [], null, 0) // => false | |
isEmpty(void 0, [], null, {}) // => false. С пустым объектом такой трюк не проходит | |
// Или так, в случае если аргумент один | |
var isEmpty = (arg) => { | |
return !([arg] + ""); | |
} | |
isEmpty(null) // => true | |
isEmpty(void 0) // => true | |
isEmpty(0) // => false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment