Description & | alternative use of javascript

Source: Internet
Author: User

Description & | alternative use of javascript

I started to study Titanium again and found that its official MVC Framework (Alloy) is still quite good. At first, I learned a lot from the lack of good code, and there were few documents, so I haven't studied it in detail. Later I found that the official CodeStrong is a set of very good learning code. As long as I read the entire set of code, I believe the use of Alloy will basically be ~

While looking at its source code, it is found that many places use the following usage:

$. Clouds & ($. index. add ($. clouds ));

I didn't quite understand it at the beginning. After all, I usually used a little bit of it. After I got to google, I realized that this method was very convenient and easy to use (in fact, this method is also widely used in jquery's source code ). The following is a reference to the online explanation & | an alternative usage in javascript:
A () & B (): If true is returned after a () is executed, B () is executed and the value of B is returned. If false is returned after a () is executed, then the entire expression returns the value of a (), and B () is not executed;
A () | B (): If true is returned after a () is executed, the entire expression returns the value of a (). B () is not executed. If a () is executed () if false is returned, B () is executed and the value of B () is returned;

& The priority is higher than |

It is quite clear after reading it. Let's look at the specific code:
Alert (1 & 3 | 0) & 4); // Result 4 ①
Alert (1 & 3 | 0 & 4); // result 3 ②
Alert (0 & 3 | 1 & 4); // Result 4 ③

Analysis:

Statement ①: 1 & 3 returns 3 => 3 | 0 returns 3 => 3 & 4 returns 4
Statement ②: Execute 1 & 3 first, return 3, return 0 in execution 0 & 4, and finally compare 3 | 0 returns 3
Statement ③: Execute 0 & 3 first, return 0, return 4 in execution 1 & 4, and finally compare 0 | 4 returns 4
Note: All integers other than 0 are true, and "undefined, null, and null" is false.

Javascript is really flexible !!


How to explain words

1. Method of decoding. When interpreting words, some words only need to clarify the meaning of the keywords, and the meaning of the words will also come out. For example, to curse, first explain the "curse", which is "speak ill of others, or use vicious words to swear", and the entire meaning of the word will come out.

2. Group word method. When interpreting words, some can express the meaning of the original words as long as each word that makes up the word is a word that is similar to the original word. For example: Soft, soft-soft; beautiful-beautiful. Therefore, the soft and beautiful meaning can be interpreted as "soft, beautiful ".

3. Synonym method. When interpreting a word, some users only need to find its synonym to explain its meaning. For example: timid, its synonym is "fear", so the word of timid can be interpreted as "fear ".

4. antonym. When interpreting a word, some people can find the antonym of the word and then deny it to understand the meaning of the word. For example, the opposite of "authenticity" is "authenticity", and the negative is "not authenticity". Therefore, the meaning of hypocrisy can be interpreted as "not authenticity ".

5. Synonym and antonym synthesis. When interpreting words, some can use the synonym method and the antonym method to better understand the meaning of words. For example, enrichment can be interpreted as "sufficient, not empty ".

6. Metaphorical Display Method
It is difficult to reveal abstract concepts that are hard to be interpreted in a specific language by analogy. For example:
Bloodbath-like a bloodbath, it describes the brutal slaughter of people.

7. Integrated Analysis Method
In some words, the relationship between the meaning of the phoneme and the meaning of the word is obvious. You can analyze the meaning of the phoneme first, and then combine it to explain the overall meaning of the word. You can also analyze the meaning of the phoneme first. For example:
Indifference-indifference, indifference, and indifference; put it aside. It refers to the indifference to people and their indifference to things.
8. Contextual Method
Link the meaning of words with the language environment to reveal the meaning of words in a specific context. For example, if the word "nine dead lives" is used in the exam, you can contact the above section "the cockroach father escaped from the refrigerator" to understand it as "the story is described as a great danger and survived ".

The methods described above cannot include the interpretation of all words. When interpreting words, pay attention to connecting context to a certain language environment, and strive to cultivate your ability to understand words in combination with context. In this way, you can accurately understand the meaning of words, understand the Emotional Colors contained in words, and grasp the application scope of words.

How to explain words

1. Method of decoding. When interpreting words, some words only need to clarify the meaning of the keywords, and the meaning of the words will also come out. For example, to curse, first explain the "curse", which is "speak ill of others, or use vicious words to swear", and the entire meaning of the word will come out.

2. Group word method. When interpreting words, some can express the meaning of the original words as long as each word that makes up the word is a word that is similar to the original word. For example: Soft, soft-soft; beautiful-beautiful. Therefore, the soft and beautiful meaning can be interpreted as "soft, beautiful ".

3. Synonym method. When interpreting a word, some users only need to find its synonym to explain its meaning. For example: timid, its synonym is "fear", so the word of timid can be interpreted as "fear ".

4. antonym. When interpreting a word, some people can find the antonym of the word and then deny it to understand the meaning of the word. For example, the opposite of "authenticity" is "authenticity", and the negative is "not authenticity". Therefore, the meaning of hypocrisy can be interpreted as "not authenticity ".

5. Synonym and antonym synthesis. When interpreting words, some can use the synonym method and the antonym method to better understand the meaning of words. For example, enrichment can be interpreted as "sufficient, not empty ".

6. Metaphorical Display Method
It is difficult to reveal abstract concepts that are hard to be interpreted in a specific language by analogy. For example:
Bloodbath-like a bloodbath, it describes the brutal slaughter of people.

7. Integrated Analysis Method
In some words, the relationship between the meaning of the phoneme and the meaning of the word is obvious. You can analyze the meaning of the phoneme first, and then combine it to explain the overall meaning of the word. You can also analyze the meaning of the phoneme first. For example:
Indifference-indifference, indifference, and indifference; put it aside. It refers to the indifference to people and their indifference to things.
8. Contextual Method
Link the meaning of words with the language environment to reveal the meaning of words in a specific context. For example, if the word "nine dead lives" is used in the exam, you can contact the above section "the cockroach father escaped from the refrigerator" to understand it as "the story is described as a great danger and survived ".

The methods described above cannot include the interpretation of all words. When interpreting words, pay attention to connecting context to a certain language environment, and strive to cultivate your ability to understand words in combination with context. In this way, you can accurately understand the meaning of words, understand the Emotional Colors contained in words, and grasp the application scope of words.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.