JavaScript determines whether variables are empty null,undefined, empty arrays, empty objects (empty object), whether the string is empty or consists entirely of whitespace characters, whether the number is 0, and whether the Boolean is false.

Source: Internet
Author: User

JavaScript determines whether the variable is empty null,undefined, an empty array, an empty object, an empty objects, whether the string is empty or consists entirely of whitespace characters, whether the number is 0, and whether the Boolean is false. Because object has no length

Object.keys () applies to arrays, which return an array of enumerable instance property names to determine whether it is empty.

Using logic to judge the OR (| | As long as there is one item that is true, the next expression is no longer evaluated, regardless of the type of parameter passed in. Returns true as long as the definition of my null is met.

1 function IsNothing (e) {2     var false Null | | E = = Undefined | | Object.keys (e). length = = 0 | | /^\s*$/gim.test (e.tostring ()); 3     return isnt; 4 }

JavaScript determines whether variables are empty null,undefined, empty arrays, empty objects (empty object), whether the string is empty or consists entirely of whitespace characters, whether the number is 0, and whether the Boolean is false.

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.