SOURCE

var a = 3;
var b = 2;
//单向
if (a>b) {
    document.write(a+"<br>");
}
//双向
if (a>b) {
    document.write(a + "<br/>");
}
else {
    document.write(b + "<br/>");
}
//多向
if (a>b) {
    document.write(a+ "<br/>");
}
else if (b=2) {
    document.write(b+ "<br/>");
}
else {
    document.write(a + "<br/>");
}
//嵌套
if (a>b) {
    if (a>3) {
        document.write(a + "<br/>");
    }
    else {
        document.write(b + "<br/>");
    }
}
else {
    if (b=2) {
        document.write(b+ "<br/>");
    }
    else {
         document.write(a + "<br/>");
    }
}
document.write( "<br/>");
document.write( "<br/>");


switch (1) {
    case 1: 
    {
        document.write(1 + "<br/>");
    }
    case 2: 
    {
        document.write(2 + "<br/>");
    }
    break;
    case 3:
    {
        document.write(3 + "<br/>");
    }
    break;
    default:
    {
        document.write("default <br/>");
    }

}


//通过parseInt(num) == parseFloat(num)判断是否为整数
function isInteger(num) {
    var result = false;

    // 判断num是否是整数
    result = (parseInt(num) == parseFloat(num));

    if (result) {
        document.write(num + " is an integer" + "<br/>");
    }
    else {
        document.write(num + " is not an integer" + "<br/>");
    }

    return result;
}

//输入一个数字,代入isInteger函数判断
isInteger(15);
//输入一个数字,代入isInteger函数判断
isInteger(15.15);
document.write(  "<br/>");

//水仙花数
function printDaffodilNumber() {

    document.write("Print out all daffodil number: " + "<br/>");

    for (var num = 100; num < 1000; ++num) {
        var unitsDigit = num % 10;
        var tensDigit = parseInt((num / 10) % 10);
        var hundredsDigit = parseInt(num / 100);

        //判断是否是水仙花数,并输出
        var sum = Math.pow(unitsDigit, 3) 
                 + Math.pow(tensDigit, 3) 
                 + Math.pow(hundredsDigit, 3);

        if (sum == num) {
            document.write(num + "<br/>");
        }
    }
}

printDaffodilNumber();
console 命令行工具 X clear

                    
>
console