Skip to content

Latest commit

 

History

History
8 lines (7 loc) · 353 Bytes

jsTechnique.md

File metadata and controls

8 lines (7 loc) · 353 Bytes

JS Technique

配列をn個ずつに分割

  • const split = (array, n) => array.reduce((a, c, i) => i % n == 0 ? [...a, [c]] : [...a.slice(0, -1), [...a[a.length - 1], c]], [])
    • split([1, 2, 3, 4], 2) // -> [[1, 2], [3, 4]]
  • 参考元様