In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to express what is not in javascript. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
In JavaScript, it does not mean that you can use the "! =" and "! = =" operators to indicate that they are not equal; use the "! =" operator to compare whether the values of two operands are not equal, and use the "! =" operator to compare whether the values of two operands are not equal and to detect whether they are of different types.
The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.
In javascript, it is not equal to how to express.
There are four equivalence detection operators, which are detailed as shown in the table.
Equivalence detection operator
Equivalence detection operator description
= (equal) compare whether the values of two operands are equal
! = (do not want to wait) compare whether the values of the two operands are not equal
= (congruent) compare whether the values of two operands are equal and detect whether they are of the same type
! = (not equal) compare whether the values of two operands are not equal and detect whether their types are not the same
In the equality operation, we should pay attention to the following problems:
If the Operand is a Boolean, it is converted to a numeric value first, where false is converted to 0 and true to 1.
If one Operand is a string and the other is a number, try to convert the string to a number first.
If one Operand is a string and the other is an object, try to convert the object to a string first.
If one Operand is a number and the other is an object, try to convert the object to a number first.
If both operands are objects, the reference address is compared. If the reference address is the same, it is equal; otherwise it is not equal.
Example 1
The following is an equality comparison of special operands.
Console.log ("1" = = 1); / / returns true. The string is converted to the number console.log (true = = 1); / / returns true. True is converted to 1console.log (false = = 0); / / true is returned. False is converted to 0console.log (null = = 0); / / returns falseconsole.log (undefined = = 0); / / returns falseconsole.log (undefined = = null); / / returns trueconsole.log (NaN = = "NaN"); / / returns falseconsole.log (NaN = = 1); / / returns falseconsole.log (NaN = = NaN); / / returns falseconsole.log (NaN! = NaN); / / returns true
NaN is not equal to any value, including itself. Null and undefined values are equal, but they are different types of data. Null and undefined are not allowed to be converted to other types of values in equality comparisons.
Examples are as follows:
Output result:
The above content is not equal to how to express it in javascript. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.