当前位置:网站首页>将多维数组变成一维数组及数组转置
将多维数组变成一维数组及数组转置
2022-08-06 00:30:00 【Swn_】
数组维数转换
const allValue = Object.values(data)
const flatten = arr => [].concat( ...arr.map(x => Array.isArray(x) ? flatten(x) : x))
const allData = flatten(allValue)
const FANG_LIANG = allData.map(value => value['方量'])
其中:const allValue = Object.values(data) const flatten = arr => [].concat( ...arr.map(x => Array.isArray(x) ? flatten(x) : x)) const allData = flatten(allValue) const FANG_LIANG = allData.map(value => value['方量'])是将数组拍平。
数组转置
转置二维数组array
var seriesData2=[];
for(var i=0;i<array[0].length;i++){
seriesData2[i] = [];
}
for(var i=0;i<array.length;i++){
for(var j=0;j<array[i].length;j++){
seriesData2[j][i]=array[i][j];
}
}
边栏推荐
- 2022-08-05 第六小组 瞒春 学习笔记
- 横向联邦学习-梯度安全聚合
- 面部表情识别---学习笔记
- Viola-Jones检测器(VJ)---学习笔记
- 【瑞吉外卖】day01:整体介绍以及开发环境搭建
- 2022 Shandong Health Expo, China Health Industry Exhibition, Postnatal Health Exhibition, Baby Care Exhibition
- 如何克服紧张
- 分布式二级缓存组件实战(Redis+Caffeine实现)
- Solve the problems arising from the mysql statement MAX () function
- 为啥强烈禁止使用Calendar?
猜你喜欢

Kubernetes 调度器优化

Yiwei Lithium's first system product equipped with 46 series large cylindrical batteries successfully rolled off the production line

工作中常见的两种谬误

【kali-漏洞利用】(3.2)Metasploit基础(中):Armitage工具利用过程

横向联邦学习-梯度安全聚合1

从零开始用C#做产品:私人日记(14)Sqlite封装

17、学习MySQL 事务

MySQL:存储引擎

嵌入式系统驱动初级【7】——内核内存管理

FPGA IIC SLAVE 实现
随机推荐
2022 Shandong Health Expo, China Health Industry Exhibition, Postnatal Health Exhibition, Baby Care Exhibition
Qt入门(零)——Qt概述
[2022 强网杯] house_of_cat 战战兢兢的复现
阿里软件测试工程师教你如何理解线程同步异步
Day4:面试必考选择题
Kubernetes网络模型
代理缓存的问题是什么呢?
Kubernetes 实现灰度和蓝绿发布
在速率分割缓存中工作提前平滑的要求是什么呢?
How to fix wsa cannot be installed
Detailed explanation of pod
Yiwei Lithium's first system product equipped with 46 series large cylindrical batteries successfully rolled off the production line
uni-app 从零开始-页面通讯 (三)
【论文阅读】Virtual Adversarial Training: a Regularization Method for SL and SSL
Day6:面试必考选择题
云上的移动性能测试平台
物理 NFT 有什么特别之处?
什么是中间人攻击?
手把手教你CSP系列之style-src
在国信证券股票开户怎么样?安全吗?