In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.