Chrome console clear assignment and variables

前端 未结 9 1484
野的像风
野的像风 2020-12-02 13:56

I am learning JavaScript and have been doing a lot of testing in the Chrome console. Even if I clear the console, or use any of the commands I\'ve seen in other threads (

9条回答
  •  盖世英雄少女心
    2020-12-02 14:48

    Just Reload for new context with clear history and old commands execution

    Things have changed a lot on chrome dev tools. delete name does not help;

    //for example if you have declared a variable 
    `const x = 2;`
     //Now sometime later you want to use the same variable 
    `const x = 5` you will get an error 
    //if you try to delete it you will get false
    delete x;
    

    But a reload of page while console is still open. will refresh the console context and now the x is not available and you can redefine it. Hope this helps someone testing or trying things on the console of chrome. i use it a lot.

提交回复
热议问题