当前位置:网站首页>Brief introduction to JS operator
Brief introduction to JS operator
2022-07-28 12:53:00 【Xiao Yang should work hard】
Preface : I'm a freshman, Xiaobai , If there are any mistakes, please point out
Catalog
2. Increment and decrement operators
1. Arithmetic operator
1. Add (+) Normal operator
var x = 9;
var y = 8;
var z = x + y;
// The final result is 172. reduce (-) Normal operator
var x = 9;
var y = 8;
var z = x - y;
// The final result is 13. ride (*) Normal operator
var x = 9;
var y = 8;
var z = x * y;
// The final result is 724. except (/) Normal operator
var x = 6;
var y = 2;
var z = x / y;
// The final result is 35. Remainder (%) Operator
var x = 7;
var y = 2;
var z = x % y;
// The final result is the remainder 12. Increment and decrement operators
1. Pre increment : ++num Pre increment , It's self imposed 1, Be similar to num = num + 1, Abbreviation ++num, Add it first , Then return the value
2. Post increment : num++ It's self imposed 1, Be similar to num = num + 1, Abbreviation num++, Return the original value first , Post autoplus
3. Logical operators
1. Logic and &&
On both sides true To return to true, Otherwise return to false
console.log(true && false) //false;
console.log(3>2 && 1>2); //false
alert( 1 && 2 && null && 3 ); // null
2. Logic or ||
As long as one side is true Both return true, On both sides false When to return to false
console.log(true || false) //true;
console.log(3>2 || 1>2); //true
If one side is true, it is true , The output ture, False output on both sides false
3. Logic is not !
Logic is not (!) It's also called the negation , Used to take a value that is the opposite of a Boolean value , Such as true The opposite of this is false
var isOk = !true;
console.log(isOk); // false
4. Comparison operator
< Less than no. 1<2 true
> More than no. 1>2 false
>= Greater than or equal to 2>=2 true
<= Less than or equal to 3<=2 false
== Whether it is equal or not 2==2 true
!= Unequal sign 3!=2 true
!! The congruent operator
===Operands are not typed , Returns only if the values are equal and the types are equaltrue.
1. Equality operator
console.log(1 == 1); // true
console.log(1 == 2); // false
console.log(1 == true); // true
console.log(1 == '1'); // true2. Inequality operator
var a = 1;
var b = 2;
var c = '1';
console.log(a != 1); // false
console.log(a != b); // true
console.log(a != c); // false3. Greater than operator
console.log(5 > 1); // true
console.log(5 > 10); // false
console.log(5 > '5'); // false4. Greater than or equal to operator
console.log(5 >= 1); // true
console.log(5 >= 5); // true
console.log(5 >= 10); // false
console.log(5 >= '5'); // true5. Less than operator
console.log(5 < 1); // false
console.log(5 < 5); // false
console.log(5 < 10); // true
console.log(5 < '5'); // false6. Less than or equal to operator
console.log(5 <= 1); // false
console.log(5 <= 5); // true
console.log(5 <= 10); // true
console.log(5 <= '5'); // true7. Inequality operator
var a = 1;
var b = 2;
var c = '1';
console.log(a !== 1); // false
console.log(a !== b); // true
console.log(a !== c); // true5. Assignment operator

边栏推荐
猜你喜欢

scala 转换、过滤、分组、排序

SuperMap iclient3d for webgl to realize floating thermal map

Redis implements distributed locks

05 pyechars basic chart (example code + effect diagram)

Initialization examples of several modes of mma8452q

Ccf201912-2 recycling station site selection

Marketing play is changeable, and understanding the rules is the key!

线性分类器(CCF20200901)

揭秘界面控件DevExpress WinForms为何弃用受关注的MaskBox属性

Linear classifier (ccf20200901)
随机推荐
Marketing play is changeable, and understanding the rules is the key!
Leetcode:704 binary search
输入字符串,内有数字和非字符数组,例如A123x456将其中连续的数字作为一个整数,依次存放到一个数组中,如123放到a[0],456放到a[1],并输出a这些数
Under what circumstances can the company dismiss employees
leetcode 376. Wiggle Subsequence
FlexPro软件:生产、研究和开发中的测量数据分析
Can molecular modeling solve the data dilemma of AI pharmacy?
Redefinition problem of defining int i variable in C for loop
Holes in [apue] files
LeetCode 42.接雨水
Use json.stringify() to format data
Detailed explanation of the usage of C # static
Zurich Federal Institute of technology | reference based image super resolution with deformable attention transformer (eccv2022))
AVL tree (balanced search tree)
Linear classifier (ccf20200901)
sqli-labs(less-8)
Insufficient permission to pull server code through Jenkins and other precautions
What if the win11 folder cannot be opened
C structure use
GMT installation and use