Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119
Windows
Desktop
one year ago
Test name Executions per second
Array Spread 14619.4 Ops/sec
Array Apply 14936.1 Ops/sec
Tests:
  • Array Spread

    x
     
    function createDateArrayInAMonth(year, month) {
      return [...new Array(new Date(year, month, 0).getDate())].map((_, i) => new Date(year, month - 1, i + 1).toLocaleString())
    }
    createDateArrayInAMonth(2023, 10)
  • Array Apply

     
    function createDateArrayInAMonth(year, month) {
      return Array.apply(null, new Array(new Date(year, month, 0).getDate())).map((_, i) => new Date(year, month - 1, i + 1).toLocaleString())
    }
    createDateArrayInAMonth(2023, 10)