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--
This article mainly introduces "how to express the symbols in javascript". In the daily operation, I believe that many people have doubts about how to express the symbols in javascript. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to express the symbols in javascript". Next, please follow the editor to study!
"&" is also a symbol in javascript. "&" is a logical operator, meaning "logical and", which is equivalent to "and" in life; when using this operator, true is returned only if both operands are true, otherwise false is returned.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
There is also a "&" symbol in javascript.
"&" is a kind of logic operator, which means "logic and", which is equivalent to "and" in life, that is, the operation result of "logic and" is "true" when both conditions are true at the same time.
Logic and Operation "&"
Logic and operations (& &) are AND Boolean operations. Return true only if both operands are true, otherwise return false. The specific description is shown in the table.
Logic and operation first Operand, second Operand operation result truetruetruetruefalsefalsefalsetruefalsefalsefalsefalse
Logic and is a kind of short-circuit logic. If the left expression is false, the result is returned directly by short-circuit, and the right expression is no longer evaluated. The operation logic is as follows:
Step 1: calculate the value of the first Operand (left expression).
Step 2: detect the value of the first Operand. If the value of the left expression can be converted to false (such as null, undefined, NaN, 0, ", false), then the operation ends and the value of the first Operand is returned directly.
Step 3: if the first Operand can be converted to true, the value of the second Operand (the expression on the right) is calculated.
Step 4: return the value of the second Operand.
Description: logic and operation are short-circuit operations, that is, if the first Operand can determine the result, then the second Operand will not be evaluated. For logic and operations, if the first Operand is false, no matter what the second Operand is, the result cannot be true, equivalent to a short circuit to the right.
Example:
The following code uses logic and operations to detect variables and initialize them.
Var user; / / define the variable (! User & & console.log ("No assignment"); / / returns the prompt "No assignment"
Equivalent to:
Var user; / / defines the variable if (! User) {/ / conditional judgment console.log ("variable is not assigned");}
If the value of the variable user is 0 or a false value such as an empty string is converted to a Boolean value, it is false, then when the variable is assigned, it is still prompted that the variable is not assigned. Therefore, you must make sure that the logic and the expression on the left return value is a predictable value at design time.
Var user = 0; / / define and initialize the variable (! User & & console.log ("variable is not assigned"); / / returns the prompt "variable is not assigned"
The right expression should not contain valid operations such as assignment, increment, decrement, and function calls, because when the left expression is false, the right expression is skipped directly, potentially affecting subsequent operations.
At this point, the study of "how to express the symbols in javascript" is over. I hope to be able to solve your 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.