Freak613 / 1more

MIT License
49 stars 1 forks source link

ES6 vs ES5 #9

Closed Sondro closed 2 years ago

Sondro commented 2 years ago

Hi, was looking @ index.js & noticed a mix of ES6 arrow functions with ES5 functions (@ index.test.js they are all ES6 arrow functions).

Is there a performance or scoping reason for this?

Also, similarly with forEach vs for loops.

Is there a desire to convert them to one or the other or to bench them?

Freak613 commented 2 years ago

It's nothing special, mostly as general rule of thumb: if it's inline function then it's arrow, if need to use this then it's ES5 function. All exceptions are just historical, it may be result of random optimizations but generally there is no hidden performance improvement.

I'm not going to perform major refactoring until project will be feature complete or it will make maintenance hard, which is not the case at the moment.

As for micro-benchmarking I'd advice against that, as it may differ from engine to engine and from version to version. It's just a waste of time, endless run, nobody wants to maintain separate versions of libraries for each combination of factors.