DEV Community

Discussion on: 8 techniques to write cleaner JavaScript code

Collapse
 
codewithahsan profile image
Muhammad Ahsan Ayaz

Thanks Raghav,
I didn't understand the question. With const DAY_IN_MILLISECONDS = 3600 * 24 * 1000; we're performing the calculations one time and that constant can be used multiple times now. And we can definitely have a better comment around it.

Collapse
 
luishrodg profile image
Luis Rodrigues

I believe that what Raghav meant was, if you put this variable in an kind of component that calculation will be done every time that i use the component.

use this:

const DAY_IN_MILLISECONDS = 86400000 // 3600 * 24 * 1000
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
codewithahsan profile image
Muhammad Ahsan Ayaz

Oh. Yeah, definitely. This should most likely be in a constants file or something. You're right.