标签:div var 应用 计算 str fine style undefined logs
var aa="01";
var bb="1.1";
var cc="zz"
var dd=false;
var ee=1.1;
var o={
ss:1
}
var aa1=+aa; //1
var bb1=+bb;//1.1
var cc1=+cc;//NaN
var dd1=+dd;//0
var ee1=+ee;//1.1
var o1=+o.ss;//1
Infinity加Infinity 返回Infinity
-Infinity加-Infinity 返回-Infinity
Infinity加-Infinity 返回NaN
5+5 返回10
5+“5” 返回“55”
var num1=5;
var num2=10;
var message="this sum of 5 and 10 is "+num1+num2;
console.log(message);
输出:
this sum of 5 and 10 is 510
var num1=5;
var num2=10;
var message="this sum of 5 and 10 is " + (num1+num2);
console.log(message);
输出:
this sum of 5 and 10 is 15
2.减法
Infinity-Infinity //NaN
-Infinity-(-Infinity) //NaN
Infinity-(-Infinity) //Infinity
-Infinity-Infinity //-Infinity
var result1 = 5 - true; //4 true被转换成了1
var result2 = NaN-1; //NaN
var result3 = 5 - "2"; //3 "2"被转换成了2
var result4 = 5 - ""; //5 ""被转换成了0
var result5 = 5 - null; //5 null被转换成了0
"Brick"<"alphabet" //true "Brick".toLowerCase()<"alphabet".toLowerCase(); //false "23" < "3" //true 2的字符编码50 3的字符编码51 "23" < 3 //false "a" < 3 //false
null == undefined
true
"NaN"==NaN
false
NaN==NaN
false
NaN != NaN
true
false == 0
true
true == 1
true
true == 2
false
undefined == 0
false
null == 0
false
1.全等:
除了在比较之前不转换操作数之外,全等和不全等操作符没什么区别。
555 === "555"
false
555 == "555"
true
555 !== "555"
true
555 != "555"
false
undefined == null //null与undefined是不同类型的值
true
undefined === null
false
6.条件操作符
var max = (num1 > num2) ? num1 :num2;
7.赋值操作符
每个主要算术操作符都有对应的复合赋值操作符。这些操作符如下所示:
var nn = 10;
nn += 10;
20
var num = 10;
num =num +10;
20
var ss=5;
ss *=5;
25
var dd=5;
dd /=5;
1
var ff=5;
ff %=5;
0
var ee=5;
ee -=2;
3
标签:div var 应用 计算 str fine style undefined logs
原文地址:http://www.cnblogs.com/zjy1017/p/7101913.html