当前位置:网站首页>Méthode d'obtention des propriétés de l'objet JS (.Et [] méthodes)
Méthode d'obtention des propriétés de l'objet JS (.Et [] méthodes)
2022-07-06 07:21:00 【éléphants et fourmis】
jsIl y a deux façons pour les objets d'obtenir des propriétés:1.Adoption.De la façon dont 2. Adoption[]Comment
// Adoption.Comment obtenir la valeur de l'attribut,keyC'est statique
var aa = {
name: "zhang", age: 18};
console.log(aa.name);
// Adoption[]Obtenir la valeur de l'attribut, keyEst dynamique,Ça peut être une chaîne,Ou sous forme numérique
var bb = {
"apple": 3, "pear": 2}
var cc = {
1: "number1", 2: "number2"}
console.log(bb["apple"]);
console.log(cc[1]); // Notez que l'écriture ici est facilement confondue avec le tableau,ccToujours objet,Pas un tableau
// Obtenir tous les objetskeyMéthode
console.log(Object.keys(bb)); // Produits[ 'apple', 'pear' ]
边栏推荐
- Establishment and operation of cloud platform open source project environment
- 杰理之BLE【篇】
- Leetcode 78: subset
- Memory error during variable parameter overload
- Raspberry pie 3B update VIM
- Go learning --- use reflection to judge whether the value is valid
- Excel的相关操作
- Solution to the problem of breakthrough in OWASP juice shop shooting range
- word中把帶有某個符號的行全部選中,更改為標題
- Chrome view page FPS
猜你喜欢
(4) Web security | penetration testing | network security web site source code and related analysis
Babbitt | metauniverse daily must read: the group image of Chinese Internet enterprises pouring into metauniverse: "there are only various survival desires, and there is no ambition for forward-lookin
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
Go learning --- use reflection to judge whether the value is valid
SSM学习
JDBC学习笔记
Uncaught typeerror: cannot red properties of undefined (reading 'beforeeach') solution
Twelve rules for naming variables
Raspberry pie 3B update VIM
“无聊猿” BAYC 的内忧与外患
随机推荐
js对象获取属性的方法(.和[]方式)
Ble of Jerry [chapter]
Path analysis model
Bugku CTF daily question: do you want seeds? Blackmailed
You deserve this high-value open-source third-party Netease cloud music player
Ble of Jerry [chapter]
Chrome view page FPS
Jerry's ad series MIDI function description [chapter]
升级版手机检测微信工具小程序源码-支持多种流量主模式
Word delete the contents in brackets
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
word删除括号里内容
Leetcode 78: subset
Kubernetes cluster builds ZABBIX monitoring platform
网络安全基础介绍
MVVM of WPF
微信脑力比拼答题小程序_支持流量主带最新题库文件
How Navicat imports MySQL scripts
【MySQL学习笔记32】mvcc
Twelve rules for naming variables