In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to avoid the use of js, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Avoid the use of =
Here you may have questions, some people like to use =, some people like to use =, everyone's style is different, why do you force others to use =? People who are used to using = can't just because they hit the keyboard less than = =. Why not advocate the use of =?
(1) if you determine the type of variable, there is no need to use = =, as follows:
If (typeof num! = "undefined") {} var num = parseInt (value); if (num = = 10) {}
The above two examples are of certain types, one is a string and the other is an integer. There is no need to use =, just use =.
(2) if the type is uncertain, you should do the type conversion manually instead of letting others or later you guess that there is a type conversion, as follows:
Var totalPage = "5"; if (parseInt (totalPage) = 1) {}
(3) use = = does not pass when checking JSLint:
If (a = = b) {}
The output of the following JSLint:
Expected'= 'and instead saw' ='. If (a = = b) {
(4) and using = = may cause some strange phenomena, which may bury hidden dangers to the code:
Null = = undefined / / true''= ='0' / / false 0 = ='/ / true 0 = ='0' / / true''= = 0 / / true new String ("abc") = = "abc" / / true new Boolean (true) = = true / / true true = = 1 / / true
The above comparisons are all false when using =, which is more reasonable. For example, the first point that null should be equal to undefined is particularly strange, because null and undefined are two unrelated values, null should be used as an initialization null, and undefined is used to verify that a variable is undefined. This is similar to the idea of strong typing introduced in point 1.
The above is all the content of the article "how to avoid the use of js". 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.
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.