Question: I have numeric format of date `20001016083256` and I want to convert it into `datetime` format something like `yymmddhhmiss`.

Expected result is 

```
2000-10-16 08:32:56

```

Is that possible in SQL Server?

Thanks a lot

Answer: 
Because `iterations[-1]` will evaluate to `undefined` (which is slow as it has to go up the whole prototype chain and can't take a fast path) also doing math with `NaN` will always be slow as it is the non common case.

Also initializing `iterations` with numbers will make the whole test more useful.

Pro Tip: If you try to compare the performance of two codes, they should both result in the same operation at the end ...

---

Some general words about performance tests:

Performance is the compiler's job these days, code optimized by the compiler will always be faster than code you are trying to optimize through some "tricks". Therefore you should write code that is likely by the compiler to optimize, and that is in every case, the *code that everyone else* writes (also your coworkers will love you if you do so). Optimizing that is the most benefitial from the engine's view. Therefore I'd write:

```
 let acc = 0;
 for(const value of array) acc += value;

 // or
 const acc = array.reduce((a, b) => a + b, 0);

```

However in the end *it's just a loop*, you won't waste much time if the loop is performing bad, but you will if the whole algorithm performs bad (time complexity of O(n²) or more). Focus on the important things, not the loops.
To elaborate on Jonas Wilms' answer, Javascript does not work with negative indice (unlike languages like Python).

`iterations[-1]` is equal to `iteration["-1"]`, which look for the property named -1 in the array object. That's why `iterations[-1]` will evaluate to `undefined`.