当前位置:网站首页>Methods for JS object to obtain attributes (. And [] methods)
Methods for JS object to obtain attributes (. And [] methods)
2022-07-06 07:21:00 【Elephants and ants】
js There are two ways to get properties of objects :1. adopt . The way 2. adopt [] The way
// adopt . Method to get the property value ,key Is static
var aa = {
name: "zhang", age: 18};
console.log(aa.name);
// adopt [] Get attribute value , key Is dynamic , Can be a string , Or in the form of numbers
var bb = {
"apple": 3, "pear": 2}
var cc = {
1: "number1", 2: "number2"}
console.log(bb["apple"]);
console.log(cc[1]); // Note that the writing here is easily confused with array ,cc Still object , Is not an array
// Get all objects key Methods
console.log(Object.keys(bb)); // Output [ 'apple', 'pear' ]
边栏推荐
- [MySQL learning notes 32] mvcc
- Oracle database 11gr2 uses TDE transparent data encryption to report an error ora28353. If you run to close the wallet, you will report an error ora28365. If you run to open the wallet, you will repor
- SSM学习
- Markdown 中设置图片图注
- Thought map of data warehouse construction
- #systemverilog# 可綜合模型的結構總結
- 杰理之BLE【篇】
- Chrome view page FPS
- 数字IC设计笔试题汇总(一)
- word删除括号里内容
猜你喜欢
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
软件测试界的三无简历,企业拿什么来招聘你,石沉大海的简历
Summary of Digital IC design written examination questions (I)
L'auteur est mort? Ai utilise l'art pour conquérir l'humanité
The first Baidu push plug-in of dream weaving fully automatic collection Optimization SEO collection module
CDN acceleration and cracking anti-theft chain function
变量的命名规则十二条
Excel的相关操作
OpenGL ES 学习初识(1)
Leetcode59. spiral matrix II (medium)
随机推荐
Idea console color log
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
leetcode1020. Number of enclaves (medium)
After the hot update of uniapp, "mismatched versions may cause application exceptions" causes and Solutions
qt颜色与字符串、uint相互转换
The first Baidu push plug-in of dream weaving fully automatic collection Optimization SEO collection module
Ble of Jerry [chapter]
ORACLE列转行--某字段按指定分隔符转多行
#systemverilog# 可綜合模型的結構總結
SEO学习的最好方式:搜索引擎
If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]
word中如何删除某符号前面或后面所有的文字
When the Jericho development board is powered on, you can open the NRF app with your mobile phone [article]
微信公众号无限回调授权系统源码 全网首发
C - Inheritance - polymorphism - virtual function member (lower)
杰理之BLE【篇】
Summary of Digital IC design written examination questions (I)
Lesson 12 study notes 2022.02.11
微信脑力比拼答题小程序_支持流量主带最新题库文件
Ble of Jerry [chapter]