Get the App
SLTechnology News&Howtos  ›  Development  › 

The relationship between 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 039 / 03

Shulou Source: shulou.com Published: 2022-06-03 16:40:23 11月14日 Update

This article introduces the knowledge of "the relationship between 0, null, undefined, [], {}, 'and false in JS. Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

0 compared to some imaginary values:

0 and false

0==false

True

0 and'':

0 million dollars.

True

0 and []:

0percent = []

True

0 and NaN:

0==NaN

False

0 and undefined

0==undefined

False

0 and null

0==null

False

0 and {}

Zero = {}

False

'' comparison of null values with some values

'' = falsetrue''==undefinedfalse''==nullfalse''==NaNfalse''== [] true''== {} false

The null value is equal to that of false, []

Undefined = = null== > true

I don't know what these values are called, and whether these values are equal can be used in some js.

Next, I would like to add the relationship among undefined,null, empty string and false,true in js.

Because seeing undefined,null in other books, empty string can be used as false in if statement judgment, so we always think that undefined,null, empty string and false are equal.

Some time ago, I stumbled upon nudefined==null; while writing code, but these two are not equal to empty characters and false;. To figure out the relationship between them, I tried them again on the browser; here are the experimental results.

False is Boolean;''is string; they are equal when their data types are not considered; they are not equal when data types are considered

It is found that the data type of null is object; whether or not the data type is considered, null characters and spaces are not equal.

When character types are not considered, it is found that undefined equals null. When character types are considered, undefined is not equal to null.

So much for the introduction of the relationship between 0, null, undefined, [], {}, 'and false in JS. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Type between empty character data character content more knowledge experiment utility learning next code dilemma string actual that is situation article time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi Microsoft Docker MariaDB