随笔分类 - js
摘要:顶层对象 es5:window对象, node:global对象 var a = 1; // 全局变量 window.a // 1 全局变量的赋值等同于顶层对象的赋值,(window对象) let b = 1; //全局变量window.b // undefined let命令、const命令声明的
阅读全文
摘要:Object.freeze() 冻结一个对象,对对象增删改都不可以 const obj = { prop: 42 }; Object.freeze(obj); obj.prop = 33; console.log(obj.prop);// 42 const obj = { prop: 42 }; o
阅读全文
摘要:const声明常量,只读、值不能改变。 const PI = 3.1415; PI = 3; // Uncaught TypeError: Assignment to constant variable. 声明必须赋值 const PI //Uncaught SyntaxError: Missing
阅读全文
摘要:块级作用域必须有大括号 if (true) let x = 1; // 报错 if (true) { let x = 1; } if (true) var x = 1; // 正常 if (true) { var x = 1; } 块级作用域内声明的函数,对作用域之外没有影响 function f(
阅读全文
摘要:Javascript的函数表达式: var a= function(){ } 函数表达式没有提升 a(); // Uncaught TypeError: a is not a function var a = function () { console.log('bar'); }; 函数声明: fu
阅读全文
浙公网安备 33010602011771号