js的惰性声明, js中声明过的变量(预解释),后在不会重新声明了

[js]js的惰性声明, js中声明过的变量(预解释),后在不会重新声明了

fn();  // 声明+定义 js中声明过一次的变量,之后在不会重新声明了
function fn() {
    console.log("ok")
}

fn(); //ok

fn = 22; //赋值是允许的
fn(); // Uncaught TypeError: fn is not a function

function fn() { console.log("ok !!!");}
fn(); //Uncaught TypeError: fn is not a function

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
相关资源
相似解决方案