2

I print an array for debug purpose with console.log() to a file in my Electron app but it only shows the first items. Is there an option to print the last items instead?

Example:

console.log(data)

instead of:

{
  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
  ]
}

having:

{
  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
  ]
}
1
  • 2
    console.log(JSON.stringify(data)) now you will see all of your data Commented Apr 14, 2020 at 13:32

1 Answer 1

6

Just use .reverse() on the array:

console.log({ ...data, currents: data.currents.reverse() })

Not the answer you're looking for? Browse other questions tagged or ask your own question.