当前位置:网站首页>JS how to get the values of multiple objects in an array
JS how to get the values of multiple objects in an array
2022-06-12 12:23:00 【Cherry*】
data: [
{
"num": 1.81,
"time": "2021-04-06"
}, {
"num": 1.82,
"time": "2021-04-07"
}, {
"num": 1.8,
"time": "2021-04-08"
}, {
"num": 1.91,
"time": "2021-04-09"
}, {
"num": 1.8,
"time": "2021-04-10"
}, {
"num": 1.81,
"time": "2021-04-11"
}
]
// Define an array to store time
let timeArr = [];
this.data.forEach((item)=>{
timeArr.push(item.time)
})
console.log(timeArr)
// result ["2021-04-06", "2021-04-07", "2021-04-08", "2021-04-09", "2021-04-10", "2021-04-11"]
forEach() Method is used to call each element of an array , And pass the element to the callback function . Be careful : forEach() Callbacks are not performed for empty arrays .
push() Method to add one or more elements to the end of an array , And returns the new length . Be careful : The new element will be added at the end of the array . This method changes the length of the array .
边栏推荐
- Tron API wave field transfer query interface PHP version package based on thinkphp5 attached interface document 20220602 version deployed interface applicable to any development language
- Rust语言学习
- golang的channel和条件变量在单生产单消费场景下的性能对比测试
- Dom and BOM in JS
- 鸡尾酒排序
- Differences between server-side rendering and client-side rendering (advantages and disadvantages)
- 服务端渲染与客户端渲染的区别(优缺点)
- [transfer]placement NEW
- QT adds a summary of the problems encountered in the QObject class (you want to use signals and slots) and solves them in person. Error: undefined reference to `vtable for xxxxx (your class name)‘
- object.defineProperty 基本使用
猜你喜欢

Dom and BOM in JS

JS built in object

LeetCode 1037. Effective boomerang (vector cross product)

Reprint --win10 open the task manager to solve the blue screen problem

Kdd2022 | edge information enhancement graph transformer

Batch load/store instructions of arm instruction set

点云配准--gicp原理与其在pcl中的使用

Longest string without duplicate characters (leetcode 3)

Create servlet project

Ros- resolve error "tf2\u buffer\was not declared in this scope"
随机推荐
回溯法, 八皇后
for in 与Object.keys()的区别
关于报文
Multiplication instruction of arm instruction set
Load/store access instruction of arm instruction set (2)
LeetCode_二分搜索_中等_162. 寻找峰值
【Leetcode】221. Largest Square
Find the median of two ordered arrays (leetcode 4)
Cocktail sort
Congratulations to splashtop for winning the 2022 it Europa "vertical application solution of the year" award
Rust language learning
win7注册进程外组件, 服务, 以及COM组件调试
MVC mode, encryption, jsonwebtoken
mysql复习
单页面开发与多页面开发的优缺点
Imx6 uboot add lvds1 display
The direction of this
Conversion between ROS map picture pixels and map coordinate system coordinates
Bank layout meta universe: digital collections, digital employees become the main track!
Advantages and disadvantages of single page development and multi page development