zoukankan      html  css  js  c++  java
  • JS_关键字详细

    break

    for(var i=0;i<10;i++){
        if(i==3) break;
        console.log(i)  //1,2,3
    }

    switch , case

    function main(arg){
        switch(arg){
            case 1:
                console.log(1);
                break;
            case 2:
                console.log(2);
                break;
            case 3:
                console.log(3);
                break;
        }
    }
    main(3);  //3

     

    try , catch

    try{
        console.log(main)
    }catch(e){
        console.log(e)  //main is not defined
    }

    continue

    for(var i=0;i<5;i++){
        if(i==2) continue;
        console.log(i)  //0,1,3,4
    }

    default

    function main(arg){
        switch(arg){
            case 1:
                console.log(1);
                break;
            case 2:
                console.log(2);
                break;
            case 3:
                console.log(3);
                break;
            default:
                console.log(null)
        }
    }
    main(4);  //null

    delete

    var person = {
        name:"sao",
        age:"18"
    }
    console.log(person.name);  //sao
    delete person.name;
    console.log(person.name);  //undefined

    do while , while

    var num = 6;
    do{
        console.log(num);  //6
        num++
    }
    while(num<5);
    /*----------------------*/
    var num = 3;
    while(num<5){
        console.log(num);  //3,4
        num++
    };

    if else

    var i = 0
    if(i==0){
        console.log(true)  //true
    }

    finally

    try{
        console.log(main)
    }catch(e){
        console.log(e)  //main is not defined
    }finally{
        console.log("finally")  //finally
    }

    for in

    var person = {
        name:"sao",
        age:"18"
    }
    for(var i in person){
        console.log(i)  //name,age
    }

    void , function

    void function(){
        console.log("hello")  //hello
    }()

    var , new

    var name = new String("sao");
    console.log(name)  //sao

    return

    function main(){
        return console.log("hello")
    }
    main();

    throw , typeof

    try{
        throw null
        console.log(main)
    }catch(e){
        console.log(typeof e)  //object
    }

    this

    function main(){
        console.log(this)
    }
    main.call(new String("sao"));

    with

    var person = {
        name:"sao",
        age:"18"
    }
    with(person){
        console.log(name)
    }

    instanceof

    var main = new String("sao");
    console.log(typeof main);
    console.log(main instanceof String);

    PS:

    void function(){
        try{
            var main = new Object();
            main.name = "sao";
            main.age = new Number("18");
            do{
                with(main){
                    if(age == 18 && age instanceof Number){
                        throw 0;
                    }else{
                        throw 1;
                    }
                }
            }while(main.age != 18)
        }catch(e){
            switch(e){
                case 0:
                    for(var i in main){
                        if(typeof main[i]=="string"){
                            delete main.name
                            continue;
                        }
                    }
                    break;
                case 1:
                    break;
                default:
            }
        }finally{
            (function(){
                alert(this.age)  //18
            }).call(main)
            return;
        }
    }()
  • 相关阅读:
    qunar面试题及一位大牛的解答
    深入理解js里面的this
    用js实现的一个可拖动标签的例子
    Linux启动详细过程(开机启动顺序)
    linux下用top命令查看cpu利用率超过100%
    linux内核内存管理(zone_dma zone_normal zone_highmem)
    用户线程与内核线程如何映射?
    Linux用户空间与内核地址空间
    linux超级块和inode 详解 和 df 、du 命令详解与环境变量
    内核空间、进程和线程等概念
  • 原文地址:https://www.cnblogs.com/somesayss/p/2857996.html
Copyright © 2011-2022 走看看