Home >Web Front-end >CSS Tutorial >How to filter out false, null, 0, '', undefined, and NaN values in a js array
This time I will show you how to filter out false, null, 0, "", undefined, and NaN values in the js array. What are the precautions for filtering out false, null, 0, "", undefined, and NaN values? The following is a practical case, let's take a look.
For false, null, 0, undefiend, NaN, take it directly! All the results are true, so here you only need to judge the empty stringfunction bouncer(arr) { // Don't show a false ID to this bouncer. return arr.filter(function(val){ return !(!val || val === ""); }); }I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the
other related articles on the php Chinese website!
Related reading:How to determine the browser IE 6 7 8 9
How to solve the problem of IE11 textarea not wrapping This BUG
The above is the detailed content of How to filter out false, null, 0, '', undefined, and NaN values in a js array. For more information, please follow other related articles on the PHP Chinese website!