How to filter out false, NULL, 0, "", Undefined, and Nan values in the JS array

Source: Internet
Author: User
This time to everyone how to filter out in the JS array false, NULL, 0, "", Undefined, and Nan these values, in the JS array to filter out false, NULL, 0, "", Undefined, and Nan these values of the considerations of what, under Face is the actual case, take a look.

For False,null,0,undefiend,nan Direct Fetch! The resulting is true, so here only the empty string "" is judged;

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

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Related reading:

How to tell the browser IE 6 7 8 9

How to solve IE11 textarea do not change the line this bug

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.