Home > Web Front-end > JS Tutorial > Introduction to Boolean type analysis based on JavaScript data types_Basic knowledge

Introduction to Boolean type analysis based on JavaScript data types_Basic knowledge

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:36:10
Original
1637 people have browsed it

clip_image002

Today we are talking about a Boolean type among data types, which returns two literal values ​​of true and false. It should be noted that literal values ​​are case-sensitive, that is, except for lowercase, everything else is just an identifier.

The following mainly talks about various data types and corresponding conversion rules:

Data type Value converted to true Value converted to false

-------------------------------------------------- ----------------------------------

Boolean true true

String   Any non-empty string   ""(empty string)

Number Any non-zero numeric value 0 and Nan

Object Any object null

Undefined  Not applicable     


-------------------------------------------------- ----------------------------------

These conversion rules are very important for understanding flow control statements (such as if statements) and automatically performing corresponding Boolean conversions. Please see the following code:

Copy code The code is as follows:

var msg="Hello World";
if(msg){
alert("Valus is true"); }

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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template