当前位置:网站首页>Basics of operators
Basics of operators
2022-06-27 22:32:00 【Program Altman】
Operator
Arithmetic operator
When it comes to computation , Space before and after is required , +: There are strings involved , Will become a splice -: Try to turn the data on both sides into numerical values , * , / %: model , Remainder , Big model small , Remainder , Small mold big , Take small , **
let num = 1 + 2;
let num1 = "1" + 2
console.log(num);//3
console.log(num1);//12
// 100 Set to style Inside width top left "100px"
let num3 = 100 + "px"
console.log(num3);
let a;
let num3 = "123" - a
console.log(num3); //NaN
let num3 = 100 / 0
console.log(num3); //Infinity
let num = 0 / 0
console.log(num);//NaN
let num = 6 % 5
console.log(num); //1
let num3 = 4 % 9
console.log(num3); //4
let num4 = 3 ** 3
console.log(num4);//27
Assignment operator
let obj = {
name:' Finch ',
age:3
}
let a = obj.age
obj.age = 108
console.log(a);//3
let obj = {
name:' Finch ',
age:[1,2]
}
let a = obj.age
obj.age[0] = 2
console.log(a[0]);//2
In front of ++ And post ++ The difference between
The pre and post values are not assigned , The result is the same ,
When there is an assignment : In front of : Evaluate first and then assign , After : Assign first , In the operation
let num = 1
// num = num + 1
num += 5
console.log(num); //2
// No assignment behavior
let num = 9
++num
console.log(num); //10
// There is assignment behavior
let x = 9
let num1 = ++x // The preposition needs to be calculated first , In assignment
console.log(num1);//10
let y = 9
let num2 = y++ // The postposition needs to be assigned first , Post operation
console.log(num2);//9
Comparison operator
It usually appears when judging the conditions , Returns a Boolean value by comparison , If the conditions are met true, If the condition is not met, it is false
=
<
<=
== Judge whether they are equal Do not look at the data type equal true It's not equal false
!=
The above comparison operators If one side is numerical , Will try to turn the other side into a numerical value to compare the size
=== All equal to Strict comparison The type is required to be consistent There is no type conversion
!== It's not equal to Strict comparison
let bool = 2 > 1
console.log(bool); //true
let bool = undefined === undefined
console.log(bool); //true
let bool = NaN === NaN
console.log(bool); //false
let bool = [] === []
console.log(bool);//false
let arr = [] //[]1 The address of
let arr1 = arr //[]1 The address of
console.log(arr === arr1); //true
let bool = {
} === {
}
console.log(bool); //false
let bool = {
} == {
}
console.log(bool); //false As long as it's a different object It's not equal
Logical operators
&& And : encounter true Just through , encounter false Just stop and return the value ,( Too true to leave , Like fake )
|| or : encounter false Just through , encounter true Just stop and return the value ( Leave the real thing after the holiday , Like the real thing )
! Not : Take the opposite To the opposite Boolean value !! Take two reverses , Then it becomes the Boolean value of the transformation corresponding to the value
Priority is not first and then or
let a = 1 && 0
console.log(a); //0
let a = 1 && 2 && "123"
console.log(a) //123;
let zq = "" && [1] || null || function(){
}
console.log(zq); //fun
边栏推荐
- Stm32cubeide1.9.0\stm32cubemx 6.5 f429igt6 plus lan8720a, configure eth+lwip
- VMware virtual machine PE startup
- Codeforces Round #719 (Div. 3)
- Go from introduction to practice -- shared memory concurrency mechanism (notes)
- 对话乔心昱:用户是魏牌的产品经理,零焦虑定义豪华
- Codeforces Round #723 (Div. 2)
- Introduction to ARCS Model
- 6G显卡显存不足出现CUDA Error:out of memory解决办法
- Simulink method for exporting FMU model files
- Read write separation master-slave replication of MySQL
猜你喜欢

AQS SOS AQS with me

登录凭证(cookie+session和Token令牌)

关于davwa的SQL注入时报错:Illegal mix of collations for operation ‘UNION‘原因剖析与验证

6G显卡显存不足出现CUDA Error:out of memory解决办法

Go language slice vs array panic: runtime error: index out of range problem solving

The create database of gbase 8A takes a long time to query and is suspected to be stuck
扁平数组和JSON树的转换

对话乔心昱:用户是魏牌的产品经理,零焦虑定义豪华

CUDA error:out of memory caused by insufficient video memory of 6G graphics card

Test birds with an annual salary of 50w+ are using this: JMeter script development -- extension function
随机推荐
Simulink method for exporting FMU model files
Is flush stock trading software reliable?? Is it safe?
Go from introduction to actual combat - only any task is required to complete (notes)
The karsonzhang/fastadmin addons provided by the system reports an error
It smells good. Since I used Charles, Fiddler has been completely uninstalled by me
How many ways does selenium upload files? I don't believe you have me all!
VMware virtual machine PE startup
Acwing week 57 longest continuous subsequence - (binary or tree array)
对话乔心昱:用户是魏牌的产品经理,零焦虑定义豪华
Day8 - cloud information project introduction and creation
Where can I set the slides on the front page of CMS applet?
\w和[A-Za-z0-9_],\d和[0-9]等价吗?
mysql 大于 小于 等于符号的表示方法
Golang uses regularity to match substring functions
Flask application case
管理系统-ITclub(下)
How to open an account for agricultural futures? How much is the handling charge for opening an account for futures? Who can give you a preferential handling charge?
读写分离-Mysql的主从复制
. Net learning notes (V) -- lambda, LINQ, anonymous class (VaR), extension method
登录凭证(cookie+session和Token令牌)