当前位置:网站首页>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
边栏推荐
- Acwing weekly contest 57- digital operation - (thinking + decomposition of prime factor)
- Test birds with an annual salary of 50w+ are using this: JMeter script development -- extension function
- 7 jours d'apprentissage de la programmation simultanée go 7 jours de programmation simultanée go Language Atomic Atomic Atomic actual Operation contains ABA Problems
- Educational Codeforces Round 108 (Rated for Div. 2)
- 管理系统-ITclub(上)
- 宏任务、微任务理解
- xpath
- 軟件測試自動化測試之——接口測試從入門到精通,每天學習一點點
- 《7天學會Go並發編程》第7天 go語言並發編程Atomic原子實戰操作含ABA問題
- 爬虫笔记(2)- 解析
猜你喜欢
爬虫笔记(3)-selenium和requests
Fill in the blank of rich text test
Use Fiddler to simulate weak network test (2g/3g)
average-population-of-each-continent
《7天学会Go并发编程》第7天 go语言并发编程Atomic原子实战操作含ABA问题
Management system itclub (Part 2)
《7天学会Go并发编程》第六天 go语言Sync.cond的应用和实现 go实现多线程联合执行
使用sqlite3语句后出现省略号 ... 的解决方法
\w和[A-Za-z0-9_],\d和[0-9]等价吗?
6G显卡显存不足出现CUDA Error:out of memory解决办法
随机推荐
年薪50W+的测试大鸟都在用这个:Jmeter 脚本开发之——扩展函数
Exclusive interview with millions of annual salary. What should developers do if they don't fix bugs?
Solution to the error of VMware tool plug-in installed in Windows 8.1 system
Crontab scheduled task common commands
渗透学习-靶场篇-pikachu靶场详细攻略(持续更新中-目前只更新sql注入部分)
美团20k软件测试工程师的经验分享
[MySQL] database function clearance Tutorial Part 2 (window function topic)
Is flush stock trading software reliable?? Is it safe?
Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
管理系统-ITclub(中)
解决本地连接不上虚拟机的问题
读写分离-Mysql的主从复制
Penetration learning - shooting range chapter -dvwa shooting range detailed introduction (continuous updating - currently only the SQL injection part is updated)
Acwing weekly contest 57- digital operation - (thinking + decomposition of prime factor)
crontab定时任务常用命令
Go from introduction to practice -- definition and implementation of behavior (notes)
对话乔心昱:用户是魏牌的产品经理,零焦虑定义豪华
[MySQL practice] query statement demonstration
Management system itclub (Part 1)
Codeforces Round #719 (Div. 3)