当前位置:网站首页>Object. Usage of keys()
Object. Usage of keys()
2022-07-04 16:45:00 【Elephants and ants】
Object.keys(obj)
- Parameters : To return an object that enumerates its own properties
- Return value : An array of strings representing all enumerable properties of a given object
1. Deal with people , Returns an enumerable array of properties
let person = {
name:" Zhang San ",age:25,address:" Shenzhen ",getName:function(){
}};
console.log(Object.keys(person));
Object.keys(item.alarmAttribute || {
}).length)
2. Handling arrays , Returns an array of index values
let arr = [1,2,3,4,5,6];
console.log(Object.keys(arr)); //["0", "1", "2", "3", "4", "5"]
3. Processing strings , Returns an array of index values
let str = "ikun Hello ";
console.log(Object.keys(str)); // ["0", "1", "2", "3", "4", "5"]
4. Common skills
let person = {
name:" Zhang San ",age:25,address:" Shenzhen ",getName:function(){
}};
Object.keys(person).map((key)=>{
console.log(person[key]); // Get the corresponding value of the attribute , Do something about it
})
Project use
Object.keys(dvehicleInfo).forEach(key => {
if (key === "containervolume" && dvehicleInfo[key] === "") {
this.Volume_Static = 1;
if (dvehicleInfo.container) {
dvehicleInfo.container.split(",").map((item, index) => {
this.containerOptions[index].len = item;
});
}
}
边栏推荐
- 基于check-point实现图数据构建任务
- Transformer中position encoding实践
- [Chongqing Guangdong education] National Open University spring 2019 1248 public sector human resource management reference questions
- Understand asp Net core - Authentication Based on jwtbearer
- JS to realize the countdown function
- Research Report on market supply and demand and strategy of China's plastics and polymer industry
- Preliminary practice of niuke.com (10)
- 同构图与异构图CYPHER-TASK设计与TASK锁机制
- 力扣今日题-1200. 最小绝对差
- Sql实现Split
猜你喜欢
Hidden communication tunnel technology: intranet penetration tool NPS
Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"
Common knowledge of unity Editor Extension
AI system content recommendation issue 24
Transformer中position encoding实践
165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
DC-2靶场搭建及渗透实战详细过程(DC靶场系列)
Penetration test --- database security: detailed explanation of SQL injection into database principle
Cut! 39 year old Ali P9, saved 150million
Overview of convolutional neural network structure optimization
随机推荐
Hair growth shampoo industry Research Report - market status analysis and development prospect forecast
Overview of convolutional neural network structure optimization
[Previous line repeated 995 more times]RecursionError: maximum recursion depth exceeded
The new generation of domestic ORM framework sagacity sqltoy-5.1.25 release
表单传递时,如何隐式将值传过去
Four point probe Industry Research Report - market status analysis and development prospect prediction
Inside and outside: flow chart drawing elementary: six common mistakes
Digital recognition system based on OpenCV
Accounting regulations and professional ethics [8]
[Chongqing Guangdong education] National Open University spring 2019 1248 public sector human resource management reference questions
Visual Studio 2019 (LocalDB)MSSQLLocalDB SQL Server 2014 数据库版本为852无法打开,此服务器支持782
China Indonesia adhesive market trend report, technological innovation and market forecast
System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
FIREBIRD使用经验总结
Research Report on market supply and demand and strategy of China's four sided flat bag industry
Configuration instance of Oracle listener server and client
CMPSC311 Linear Device
QT graphical view frame: element movement
The content of the source code crawled by the crawler is inconsistent with that in the developer mode
Lv166 turned over