r/javascript • • May 15 '17

Don't Overcomplicate Javascript #0

https://bits.ristic.io/dont-overcomplicate-javascript-0
35 Upvotes

34 comments sorted by

View all comments

2

u/ArcanisCz May 15 '17

Well, its not abour redux or javascript. Its "magic number" pattern dated back to C language, even assembler (for example here https://www.viva64.com/en/l/0009/).

6

u/freeall May 15 '17

Not really. Just naming a magic number doesn't make it less magical.

setTimeout(foo, 1000)

vs

var oneSecond = 1000;
setTimeout(foo, oneSecond);

vs

var timeToWaitForNetwork = 1000;
setTimeout(foo, timeToWaitForNetwork);

His point in the article is that it just adds more complexity that you now also have a variable named the same thing as a string. And without any real benefit.