Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.63
Chrome 89
Windows
Desktop
3 years ago
Test name Executions per second
Parse Date 49.3 Ops/sec
String split 82.9 Ops/sec
Script Preparation code:
AخA
 
var dateStrings = Array(10000).fill(null).map(() => (new Date()).toISOString());
var padDate = date => (date < 10 ? `0${date}` : date);
Tests:
  • Parse Date

     
    dateStrings.map((d) => {
      const date = new Date(d);
      return `${padDate(date.getDate())}.${padDate(date.getMonth() + 1)}.${padDate(date.getYear())}`;
    });
  • String split

     
    dateStrings.map((d) => {
      const [date, time] = d.split('T')
      const [year, month, day] = date.split('-');
      return `${day}.${month}.${year}`;
    });