JS中的运算

除法

Infinity 属性用于存放表示正无穷大的数值。
负无穷大是表示负无穷大一个数字值。
在Javascript中,超出 1.7976931348623157E+103088 的数值即为Infinity,小于 -1.7976931348623157E+103088 的数值为无穷小

相等判断

         alert(null == undefined);    //true
alert(null === undefined); //false
alert("NaN" == NaN); //false
alert("NaN" === NaN); //false
alert(NaN == NaN); //false
alert(NaN === NaN); //false
alert(NaN != NaN); //true
alert(NaN !== NaN); //true
alert(false == 0); //true
alert(false === 0); //false
alert(true == 1); //true
alert(true === 1); //false
alert(null == 0); //false
alert(undefined == 0); //false
alert(5 == "5"); //true
alert(5 === "5"); //false
其它的 != 与 !== 都是一样的

取模

    alert(26 % 5);          //1
    alert(Infinity % 3);    //NaN
    alert(3 % 0);           //NaN
    alert(5 % Infinity);    //5
    alert(0 % 10);          //0
    alert(true % 25);       //1
    alert(3 % false);       //NaN

乘法

    alert(5 * 6);           //30
    alert(5 * NaN);         //NaN
    alert(Infinity * 0);    //NaN
    alert(Infinity * 2);    //Infinity
    alert("5" * 5);         //25
    alert(true * 10);       //10
    alert(false * 10);      //0

null 相关

    var car = null;
    alert(typeof car);   //"object"
    alert(null == undefined);    // true

减法

    var result1 = 5 - true;    //4 because true is converted to 1
    var result2 = NaN - 1;     //NaN
    var result3 = 5 - 3;       //2
    var result4 = 5 - "";      //5 because "" is converted to 0
    var result5 = 5 - "2";     //3 because "2" is converted to 2
    var result6 = 5 - null;    //5 because null is converted to 0
    var result7 = 5 - undefined //NaN