Why is this block of code crashing Chrome but not Safari?


When running this code on Safari:

function generateTimes(timeIncrement) {
      let currentTime = '0000',
        times = [];

      do {
        times.push(currentTime);
        currentTime = moment(currentTime, 'HHmm')
          .add(timeIncrement, 'minutes')
          .format('HHmm');
      } while (currentTime !== '0000')

      return times;
 }
generateTimes(15);

You get:

Array (96) = $1
0 "0000"
1 "0015"
2 "0030"
3 "0045"
4 "0100"
5 "0115"
6 "0130"
7 "0145"
8 "0200"
9 "0215"
10 "0230"
11 "0245"
12 "0300"
13 "0315"
14 "0330"
15 "0345"
16 "0400"
17 "0415"
18 "0430"
19 "0445"
20 "0500"
21 "0515"
22 "0530"
23 "0545"
24 "0600"
25 "0615"
26 "0630"
27 "0645"
28 "0700"
29 "0715"
30 "0730"
31 "0745"
32 "0800"
33 "0815"
34 "0830"
35 "0845"
36 "0900"
37 "0915"
38 "0930"
39 "0945"
40 "1000"
41 "1015"
42 "1030"
43 "1045"
44 "1100"
45 "1115"
46 "1130"
47 "1145"
48 "1200"
49 "1215"
50 "1230"
51 "1245"
52 "1300"
53 "1315"
54 "1330"
55 "1345"
56 "1400"
57 "1415"
58 "1430"
59 "1445"
60 "1500"
61 "1515"
62 "1530"
63 "1545"
64 "1600"
65 "1615"
66 "1630"
67 "1645"
68 "1700"
69 "1715"
70 "1730"
71 "1745"
72 "1800"
73 "1815"
74 "1830"
75 "1845"
76 "1900"
77 "1915"
78 "1930"
79 "1945"
80 "2000"
81 "2015"
82 "2030"
83 "2045"
84 "2100"
85 "2115"
86 "2130"
87 "2145"
88 "2200"
89 "2215"
90 "2230"
91 "2245"
92 "2300"
93 "2315"
94 "2330"
95 "2345"

Array Prototype

But running the same code on Chrome, simply crashes it.

Why?

Source: JavaSript – Stack Overflow

October 31, 2021
Category : News
Tags: javascript | momentjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.