Warning: Attempt to read property "ID" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 471

Warning: Attempt to read property "display_name" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 480

Warning: Attempt to read property "display_name" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 487

Warning: Attempt to read property "description" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 489

Warning: Attempt to read property "ID" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 493

NODE.JS var与let区别

1.let的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效。var定义的变量为全局变量。

function f1() {
let n = 5;
if (true) {
let n = 10;
}
console.log(n); // 5
}

2.var在同一块可以重复定义,let不能

//正常
function () {
var a = 10;
var a = 1;
}

// 报错
function () {
let a = 10;
var a = 1;
}

// 报错
function () {
let a = 10;
let a = 1;
}
————————————————
版权声明:本文为CSDN博主「xczaVV」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011768758/java/article/details/63268337

评论留言