javascript - 如何在对象中使用 Javascript url 键
问题描述
我有以下对象
websites=
{
"https://google.com": "google",
"https://wix.com/myprofile":"wix",
"https://stackoverflow.com": "stackoverflow"
}
如何使用 javascript 访问值(google、wix、stackoverflow)
解决方案
您可以通过以下方式访问这些值Object[key]
:
let websites=
{
"https://google.com": "google",
"https://wix.com/myprofile":"wix",
"https://stackoverflow.com": "stackoverflow"
};
console.log(websites['https://google.com']);
推荐阅读
- ruby-on-rails - 如何将 CoreUI 添加到 rails (+ React) 应用程序?
- javascript - 防止重复的对象被添加到数组中?
- java - java netbeans IDE 8.2中的扫描仪导入问题
- reactjs - 在 ReactJS 中多次 setState 后捕获状态值
- python-3.x - 如何以简单的方式进行累积平均值和计数
- wordpress - 如何传递链接的跟踪 ID 并将它们添加到 wordpress 页面上的出站链接
- mysql - MYSQL - 无法创建外部密钥
- unity3d - 字符串构造函数不能在统一 c# 中工作
- github - Github - 如何将我的项目提交到现有存储库的子文件夹/目录?
- machine-learning - 在 NEAT 算法中向结构添加节点/连接