did*_*dil 2 javascript node.js electron
我使用 console.log() 将用于调试目的的数组打印到我的 Electron 应用程序中的文件中,但它只显示第一项。是否可以选择打印最后一个项目?
例子:
console.log(data)
代替:
{
threshold: 60,
currents: [
15, 157, 145, 20, 18, 18, 120, 122, 58, 67,
67, 67, 415, 334, 564, 8603, 9492, 9521, 9403, 8992,
9369, 8991, 9395, 9415, 9327, 9499, 9320, 8876, 8850, 8846,
... 81 more items
]
}
Run Code Online (Sandbox Code Playgroud)
有:
{
threshold: 60,
currents: [
... 81 previous items
8913, 9409, 9446, 8935, 8869, 9448, 9542, 8875, 9454, 9540,
8926, 9988, 9390, 9532, 8864, 9503, 9422, 8880, 9428, 9465,
8896, 9319, 9381, 9404, 8878, 9473, 9491, 8896, 9627, 9522,
8979, 8866, 9545, 9510, 8872, 9536, 9497, 9556, 9556, 8911,
9958, 9578, 9243, 8861, 9408, 9418, 8911, 9471, 9447, 8906
]
}
Run Code Online (Sandbox Code Playgroud)
只需.reverse()在数组上使用:
console.log({ ...data, currents: data.currents.reverse() })
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
107 次 |
| 最近记录: |