Mas*_*ask 0 javascript google-apps-script
我有一个数组说
arr1 = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
Run Code Online (Sandbox Code Playgroud)
我想将其切片并选择第二列和第三列。
我尝试过使用切片,但没有成功。
var result = arr1.slice(1,3);
但我没有得到想要的输出
[[2,3],[6,7],[10,11]]
Run Code Online (Sandbox Code Playgroud)
是因为我使用 Google 电子表格收集数据吗?
您需要映射切片数组。
const
array = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],
customSlice = array => array.slice(1, 3),
result = array.map(customSlice);
console.log(result);Run Code Online (Sandbox Code Playgroud)
.as-console-wrapper { max-height: 100% !important; top: 0; }Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1465 次 |
| 最近记录: |