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/03 Report--
This article mainly introduces "how to understand the JavaScript operator". In the daily operation, I believe many people have doubts about how to understand the JavaScript operator. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to understand the JavaScript operator"! Next, please follow the editor to study!
Operator
1 arithmetic operator
Outline: the operator for addition, subtraction, multiplication and division, and the calculation of the remainder.
Operator: +, -, *, /,% (operation to take the remainder)
Note: floating point (decimal) operations may cause accuracy problems when performing arithmetic operations
2 increasing and decreasing operators
Operators: + +,-- (averse +, amure -, + + a,-- a)
/ / the pre-increment operator var num = 1 / or num++console.log (num) / / the result is 2 / / + + num, so num = num+ 1 hand / pre + + is to do self-increment first and then to do other operations / / pre-decrement operator var num = 1 Mattel num / or num--console.log (num) / / the result is 0 /-- num is equivalent to num = num- 1 jump / front-- is to do self-subtraction before doing other operations
3 comparison operator
Operator: >
< , >=,
< , >=, 18 & & (num=998); / / because age > 18 is not true, the logic and result is false / / so when the logic and calculation is complete, the subsequent num=998 will no longer run
Logic or (| |):
As long as a condition is true, the result of the expression is true, and only if all the conditions are not true, the result of the expression is false.
Interruption of logical OR:
Var age= 18 num;age = = 18 | (num=998); / / because the age==18 is established, the logic or the result is true / / so when the logic or calculation is complete, the subsequent num=998 will no longer run
Logic is not (!): take true as false and false as true.
Var a = 5 ×! (a > 1) / / an equals 5, so a greater than 1 is true (true), so this expression is false because it is reversed.
5 Ternary operator:?:
It can be understood as a simplified way of writing two branches of if.
Grammatical structure:
Expression 1? Expression 2: expression 3
When expression 1 is true, expression 2 is executed
When expression 1 is not valid, expression 3 is executed
The result of the operation is that if an is 3, var b is greater than 2, return b to a, and return c to a for false, because b is less than 2, so return c to a. The study on "how to understand the JavaScript operator" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.