Home > Web Front-end > CSS Tutorial > How to filter out false, null, 0, '', undefined, and NaN values ​​​​in a js array

How to filter out false, null, 0, '', undefined, and NaN values ​​​​in a js array

php中世界最好的语言
Release: 2018-03-09 15:58:56
Original
3596 people have browsed it

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 string

"";

function bouncer(arr) {  // Don't show a false ID to this bouncer.
  return arr.filter(function(val){    return !(!val || val === "");
  });
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template