ETH官方钱包

前往
大廳
主題

cocos creator Typescript學(xué)習(xí)筆記2

查理 | 2024-12-05 16:07:26 | 巴幣 0 | 人氣 17

//運算符號
//+ - * / %
let num1 = 3+2;
let num2 = 3-2;
let num3 = 3*2;
let num4 = 3/2;
let num5 = 3%2;
document.write("num1:"+num1);
document.write("num2:"+num2);
document.write("num3:"+num3);
document.write("num4:"+num4);
document.write("num5:"+num5);

let num6 =10;
num6++;
document.write("num6"+num6);

let num7= 10;
//先使用,再++ //10
document.write("num7:"+ num7++);
//先++,再使用 //12
document.write("num7:"+ ++num7);

//比較運算符號
// == >= <=
let res:boolean = 5>3;
document.write("res:"+res);

let num8 =3;
let res1:boolean = num8==3;
document.write("res1:"+res1);

// == 只判斷結(jié)果,不判斷類型 true
let num9 = "3";
let res2:boolean = num9 == 3;
document.write("res2:"+res2);
// === 判斷結(jié)果,也判斷類型 false
let num10 = "3";
let res3:boolean = num10 === 3;
document.write("res3:"+res3);

//!=
let num11 = "3";
let res4:boolean = num11 != 10;
document.write("res4:"+res4);

// && 邏輯與
let num12=5;
let num13=6;
let res5 = num12>0 && num13 >0;
document.write("res5:"+res5);
// || 邏輯或
let num14=5;
let num15=6;
let res6 = num14>0 || num15 >10;
document.write("res6:"+res6);

// !true 邏輯非
let res7 =!(11>10);
document.write("res7:"+res7);

//賦值運算符
let num16:number =3;
//num16 = num +3;
num16 +=3;
document.write("num16:"+num16);

創(chuàng)作回應(yīng)

更多創(chuàng)作