当前位置:网站首页>JS Object.keys()
JS Object.keys()
2022-07-16 07:09:00 【黎&&轩】
返回一个对象键名组成的数组,需要IE9+支持
1.对象处理,返回枚举属性数组
const person = {
name:"Jerry",
age:18,
gender:"male"
}
console.log(Object.keys(person))//["name", "age", "gender"]
2.数组处理,返回索引数组
let arr = [1,2,3,4,5,6]
console.log( Object.keys(arr) )

3.字符串处理,返回索引值数组
let str = "saasd字符串"
console.log( Object.keys(str) )
描述对象的enumerable属性,称为“可枚举性”,如果该属性为false,就表示某些操作会忽略当前属性。
目前,有四个操作会忽略enumerable为false的属性。
for...in循环:只遍历对象自身的和继承的可枚举的属性。Object.keys():返回对象自身的所有可枚举的属性的键名。JSON.stringify():只串行化对象自身的可枚举的属性。Object.assign(): 忽略enumerable为false的属性,只拷贝对象自身的可枚举的属性。
前三个是ES5就有的,最后一个Object.assign()是 ES6 新增的。
参考ES6 入门教程
边栏推荐
- Distributed notes (01) - theory and principle of distributed cap
- How much does it cost for lazada, express and shopee to evaluate self-supporting numbers?
- ONNX模型tensor shapes inference和Flops统计工具
- Xiaomi mobile safely uninstalls built-in applications
- Characteristics of Lora technology in wireless communication
- Kotlin SQLite URL转义字符(Escape)(一)
- Optimization of AI model structure based on nvidiagpu
- ES的操作
- 重新认识你的NFT
- Vulnhub-dc8 learning notes
猜你喜欢

景联文科技数据采集公司:严格把控工期,为AI企业输送高质量数据

Could not get lock /var/lib/dpkg/lock-frontend

Know Baidu AI development platform

亚马逊卖家该如何做好防关联?不砍单!(测评自养号详解)
![[server data recovery] a case of RAID5 data recovery of an IBM model storage](/img/7b/5c8b36ea91f0cef878a01b3c00f16f.jpg)
[server data recovery] a case of RAID5 data recovery of an IBM model storage

Tensorflow2.0 advanced learning RNN generated audio (12)

CVPR 2022 | improve the utilization efficiency of small data sets, Fudan et al. Proposed layered cascaded vit network

Soft exam (intermediate software designer) exam information

Fun ping command

El input number disable scientific counting without result, and replace it with El input (type= "number")
随机推荐
Comprehensive evaluation method
Mipi CSI, DSI, UFS, c-phy, d-phy, m-phy concept understanding
第三篇章:运行时数据区——独立空间
Information retrieval summit sigir2022 best paper award came out, Melbourne Institute of technology best paper, UMass University and other best short papers
澳大利亚规模领先的鞋业公司与Boomi合作以加快电子商务和转型步伐
Establishment of APP automated test framework (VII) -- airtest basic operation
综合评价方法
PostgreSQL 现在安装
El input number disable scientific counting without result, and replace it with El input (type= "number")
移远通信助力夏粮存储新招式,科技手段更有效
86触摸开关/台扇/空调/智能家居/家电等,低功耗高抗干扰3键3路3通触摸IC-VK3603 ESOP8,性能稳定,灵敏度可调
书写更自然,媲美原厂体验,南卡Pencil电容笔上手
RMAN详细教程(二) —— 备份、检查、维护、恢复
HMS core graphics and image technology shows the latest functions and application scenarios, and accelerates the construction of digital intelligence life
cron 表达式周一到周五执行以及只有周六周天执行
[server data recovery] a case of RAID5 data recovery of an IBM model storage
[daily training] 558 Intersection of quadtree
Kotlin SQLite URL escape character (escape) (I)
【LeetCode】11. Lowest common ancestor of a binary search tree
【服务器数据恢复】IBM某型号存储RAID5数据恢复案例