首页
JavaScript正文
Javascript 中使用 const 与 freeze 的声明
文章标签
声明
javascript 常量
使用 const 我们仍然可以修改 javascript 对象的内容,但对该对象的引用将是不可变的。
const product = {name: "sugar", weight: "1 kg"};product.name = "some new name";console.log(product);
{ name: "some new name", weight: "1 kg"}
javascript 冻结
当我们不想修改对象的内容时,首选使用 freeze。
const product = {name: "sugar", weight: "1 kg"};object.freeze(product);product.name = "some new name";console.log(product);
{ name: "Sugar", weight: "1 kg"}
文章推荐
-
JavaScript如何获取宏控件数据?
javascript 获取宏控件数据的方法有两种:get("value"):获取输入框、文本区域和选择列表的 value...
JavaScript
2天前 14 -
JavaScript怎样读取宏控件数据?
是的,可通过以下步骤读取宏控件数据:获取宏控件元素检查宏控件类型(例如,activex 或 java 插件)获取宏控件对...
JavaScript
2天前 9 -
JavaScript获取宏控件数据的技巧
用 javascript 获取宏控件数据包含以下步骤:获取宏控件对象。获取宏控件属性,如 classid。执行宏控件方法...
JavaScript
2天前 9 -
探究JavaScript与Java的联系和区别
javascript 和 java 虽然名称相似,但它们是两种截然不同的语言,主要区别在于:1. 语法不同;2. 编译方...
JavaScript
2天前 10 -
javascript:void(o)如何解决?
解决 javascript:void(o) 错误的步骤:检查链接是否指向预期脚本。使用文本编辑器或 javascript...
JavaScript
2天前 9
最新文章