search
Homephp教程PHP开发Understanding boolean types in javascript

Speaking of the Boolean type, I believe anyone who has had programming experience knows what it is. But the Boolean type in Javascript is very interesting.

 First of all, it is used to determine whether it is true or false, not just true or false. , it seems that any object can be used as a Boolean judgment. Do you have a sense of accomplishment that "everything in the world is for my use"? I checked it online and copied it from elsewhere and summarized it as follows:

 1. All objects are considered is true.

 2. A string is considered false if and only if it is empty ("" or '').

 3. Null and undefined are considered false.

 4. A number is false if and only if it is 0.

 So it is very convenient to use. If you want to judge whether there is an object on the page, just use this sentence:

if(button)
{
 alert("exist");
}
else
{
 alert("SORR\, does not exist");
}

Isn't it very convenient? Using this well can reduce a lot of code for judgment in javascript.

The above is the management of Boolean type content in javascript. For more related articles, please Follow the PHP Chinese website (www.php.cn)!


Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.