javascript - 新的 Javascript Const 关键字使用
问题描述
我正在尝试学习 JavaScript 代码,但以下是一些陈述。我无法理解。
const node = active[data]; // Is the code assiging a value to the node
const subviews = view.subviews(); // What does view.subviews() means
const view = node.instance; // What does node.instance means
this.className = view.$className; // What does $ sign means
this._enabled = null; // Why enabled was used since there was no object declared wit name _enabled.
有人可以解释为什么使用上述语句吗?
解决方案
这些示例中的大多数最有可能用于混叠目的。
例如。
const node = active[data];
node.value = 7;
node.qty = 8;
将与
active[data].value = 7;
active[data].qty = 8;
附言。价值和数量只是我编造的属性。
IOW:它省去了active[data]
不断打字的麻烦。
另一种选择是使用with
,但这是不受欢迎的,而且容易出错。
推荐阅读
- python - 到/来自列表的字典的字典列表,但具有所有可能的排列
- excel - 如何获取列表中的第一个名字或只提取唯一的名字?
- microsoft-graph-api - Office.context.mailbox.item.getSharedPropertiesAsync() 将于 2022 年弃用?
- woocommerce - 动态更改存储位置
- amazon-web-services - 如何在不使用 AWS CLI 删除当前附加的安全组的情况下将新的安全组分配给 EC2 实例?
- mysql - 查询多对多 Unscoped 关联(已删除)
- github - 停止在更新存储库中的某些文件时触发 GitHub 操作
- python - Python WooCommerce - 通过 REST API 导入的空产品
- swift - Cocoa - 以编程方式将 menuContext 添加到 ScrollView / CollectionView
- c# - ASP.Net MVC 动态脚本包未加载并在前几次出现 404 错误