Home > Web Front-end > JS Tutorial > js basic improvement learning operators

js basic improvement learning operators

php中世界最好的语言
Release: 2018-06-04 14:02:26
Original
1443 people have browsed it

This time I will bring you the operator to improve the basics of js. What are the precautions when using js operators? Here are practical cases, let’s take a look.

1, Arithmetic operator:

+    -   *    /    %
Copy after login

There is also a special operator here that has the same function, that is %, which we call remainder , some people call it modulo.

PS: Note that splicing can be done in js, and other -, *, / can only be used for numerical calculations. In fact, whether it is js or python, there is an attribute method that can connect strings, contat(), but we don't know how to use it. Generally, we use it for linking

Self-increment and self-decrement: (a function not found in Python) - --------------------------------------------------

In order to make their code more concise, some people will use such a writing method-i

Three principles:

1. When a variable adds itself or Subtract, this variable will definitely change 1

2. Pre-add and pre-subtract, PriorityDon’t be high (one level lower than brackets ())

3. Post-addition and post-subtraction have low priority (lower than assignment symbols)

Now let me explain here that i and --i themselves do not exist and can be replaced by using basic operations. The only value here is that it is simpler and more concise

2, Logical operator:

与:&&(python中and一样)
或:| |(python中or一样),用 | (单竖杠),也可以用 || 表示。
非:!(python中not一样)
Copy after login

3,Assignment operator:

=
Copy after login

4. Binary operator:

+=     -=     *=     /=
Copy after login

5. Relational operator:

>    <     >=    <=     ==   (===)   !=
Copy after login

Absolute equality means that the value and type of the variable are equal, use === express. == only determines the value, not the type

is definitely not equal, even the values ​​of the variables are not equal, use! ==Love expressed. ===Judge both the value and the type

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

JQuery $() usage summary

REM relative unit usage case sharing

The above is the detailed content of js basic improvement learning operators. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template