Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Is there any difference between =, =, and = in javascript?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "javascript =, = =, = whether there is a difference", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "whether there is a difference between =, =, = = in javascript".

There's a difference. In javascript, "=" is the assignment operator that assigns the right value to the left variable, while "=" and "= =" are comparison operators that compare whether the expressions on the left and right sides are equal. "=" performs the necessary value type conversion before equality comparison, while "= =" does not perform the type conversion.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

The difference between =, =, = = in javascript

"=" is the assignment operator, and "=" and "= =" are comparison operators

"=" operator

"=" is the simplest assignment operator, assigning the value on the right side of the operator to the variable on the left side of the operator

"=" and "= =" operators

They are all used to compare whether the expressions on the left and right sides of the operator are equal.

"=" means equality, "= =" means strict equality.

When making a double equal sign comparison: first check the two Operand data types, if the same, then make a = = comparison, if different, then be willing to make a type conversion for you, convert to the same type and then compare it, and if the type is different, it will be false directly.

Double equal sign =:

(1) if the two values are of the same type, make a comparison of three equal signs (=)

(2) if the two value types are different, they may also be equal, and the type conversion should be carried out according to the following rules:

1) if one is null and the other is undefined, then equal

2) if one is a string and the other is a numeric value, convert the string to a numeric value and then compare it

Third class sign =:

(1) if the type is different, it must not be equal.

(2) if both are numeric values and are the same value, then they are equal; if at least one of them is NaN, then they are not equal. (you can only use isNaN () to determine whether a value is NaN.)

(3) if both are strings and the characters in each position are the same, then they are equal, otherwise they are not equal.

(4) if both values are true or false, then they are equal.

(5) if both values refer to the same object or function, they are equal, otherwise they are not equal.

(6) if both values are null or undefined, then they are equal.

The above is all the contents of this article entitled "is there any difference in javascript?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report