关注分享主机优惠活动
国内外VPS云服务器

微信小程序中常用的运算符有哪些(微信小程序中常用的运算符有哪些类型)?

基本运算符示例代码:

var a = 10,b = 20//添加console . log(30 = = = a+b);//减法console . log(-10 = = A-B);//乘法运算console . log(200 = = = a * b);//Division operation console . log(0.5 = = = a/b);//冗余操作console . log(10 = = = a % b);加法(+)也可以用作字符串的串联。

var a = & # 039。w & # 039,b = & # 039xs & # 039;//字符串串联console . log(& # 039;。wxs & # 039= = = a+b);一元运算符示例代码:

var a = 10,b = 20//自增操作console . log(10 = = = a++);console . log(12 = = = +++a);//自减量操作console . log(12 = = = a-4 ++ -);console . log(10 = = = --a);//正值operation console . log(10 = = =+a a);//负值operation console . log(0-10 = = = -a = -a);//无操作console . log(-11 = = ~ a);//Invert console.log(false ===!a);//删除operation console . log(true = = = delete a . fake);//void operation console . log(undefined = = = void a);//operation console . log(& quot;数字& quot= = =的类型);位运算符示例代码:

var a = 10,b = 20//将console.log向左移动(80 = = =(a :& gt;2));//签名右移操作console . log(2 = = =(a >:& gt;& gt2));//和operation console . log(2 = = =(a & 3));//XOR运算console . log(9 = = =(a3));//或者operation console . log(11 = = =(a | 3));比较运算符示例代码:

var a = 10,b = 20//小于console . log(true = = =(a ;b));//小于等于console . log(true = = =(a ;= b));等效运算符的示例代码:

var a = 10,b = 20//等于console . log(false = = =(a = = b));//不等于console.log(true === (a!= b));//完全平等console . log(false = = =(a = = b));//不相同的console . log(true = = = =(a!= = b));赋值运算符的示例代码:

var a = 10a = 10a* = 10;console . log(100 = = = a);a = 10a/= 5;console . log(2 = = = a);a = 10a % = 7;console . log(3 = = = a);a = 10a+= 5;console . log(15 = = = a);a = 10a -= 11;console . log(-1 = = = a);a = 10a & lt& lt= 10;console . log(10240 = = = a);a = 10a & gt& gt= 2;console . log(2 = = = a);a = 10a & gt& gt& gt= 2;console . log(2 = = = a);a = 10a & amp= 3;console . log(2 = = = a);a = 10一台^= 3;console . log(9 = = = a);a = 10a | = 3;console . log(11 = = = a);二元运算符的示例代码:

var a = 10,b = 20//Logic and console . log(20 = = =(a & amp;b));//logic or console . log(10 = = =(a | | b));其他运算符示例代码:

var a = 10,b = 20//条件运算符console.log (20 = = = (a >: = 10?a+10:b+10));//逗号运算符console.log(20 === (a,b));运算符优先级运算符说明了关联性20(& # 8230;)括号n/a19 & # 8230;。…会员从左至右参观& # 8230;[ …]会员从左至右参观& # 8230;( …)函数调用从左到右17 & # 8230;+岗位增量不适用。--后减量n/a16!…逻辑不是从右到左~ & # 8230;按位从右向左+& # 8230;一元加法从右到左-& # 8230;从右到左的一元减法++ & # 8230;从右到左递增--& # 8230;从右到左预减类型& # 8230从右到左的类型无效& # 8230;从右向左删除无效& # 8230;从右向左删除14 & # 8230;* …从左到右的乘法& # 8230;/ …从左到右的划分& # 8230;% …从左到右拿起模块13 & # 8230;+ …从左向右添加& # 8230;- …从左到右减12 & # 8230;& lt& lt…按bit left从左向右移动& # 8230;& gt& gt…按bit right从左向右移动& # 8230;& gt& gt& gt…无符号右移从左到右11 & # 8230;& lt…从左到右小于& # 8230;& lt= …从左到右小于或等于& # 8230;& gt…从左到右大于& # 8230;& gt= …从左到右大于或等于10 & # 8230;== …等号从左到右& # 8230;!= …从左到右不等号& # 8230;=== …所有等号从左到右& # 8230;!== …非等号从左到右9 & # 8230;& amp…按bit,从左到右8 & # 8230;^ …从左到右按位异或7 & # 8230;| …按bits或从左到右按6 & # 8230;& amp& amp…逻辑从左到右5 & # 8230;|| …或逻辑从左到右4 & # 8230;?…: …条件运算符从右到左3 & # 8230;= …从右向左赋值& # 8230;+= …从右向左赋值& # 8230;-= …从右向左赋值& # 8230;*= …从右向左赋值& # 8230;/= …从右向左赋值& # 8230;%= …从右向左赋值& # 8230;& lt& lt= …从右向左赋值& # 8230;& gt& gt= …从右向左赋值& # 8230;& gt& gt& gt= …从右向左赋值& # 8230;& amp= …从右向左赋值& # 8230;^= …从右向左赋值& # 8230;|= …从右向左赋值0 & # 8230;, …从左到右的逗号

相信你看完这个案例已经掌握了方法。更多精彩请关注即时码站其他相关文章!

推荐阅读:

微信小程序开发中如何实现Android环境下的水平滚动

未经允许不得转载:主机频道 » 微信小程序中常用的运算符有哪些(微信小程序中常用的运算符有哪些类型)?

评论 抢沙发

评论前必须登录!