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.
+ - * / %
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一样)
=
4. Binary operator:
+= -= *= /=
5. Relational operator:
> < >= <= == (===) !=
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:
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!