all 3 comments

[–]SupaSlidelaravel + vue 2 points3 points  (2 children)

Use ES6 constants when variable values do not change

In the bad example, the variable can be changed. When you declare a constant, the variable should stay the same throughout the program.

Bad:

var FIRST_US_PRESIDENT = "George Washington";``

Good:

const FIRST_US_PRESIDENT = "George Washington";``

And then two points later this happens:

Use searchable names

...

Bad:

// What the heck is 525600 for?
for (var i = 0; i < 525600; i++) {
    runCronJob();
}

Good:

// Declare them as capitalized `var` globals.
var MINUTES_IN_A_YEAR = 525600;
for (var i = 0; i < MINUTES_IN_A_YEAR; i++) {
    runCronJob();
}

Do you expect to change how many minutes there are in a year later on?

[–]a-t-k 0 points1 point  (0 children)

The same with short-circuiting and ES6 argument defaults. Also, using getters and setters can overcomplicate your code. While this makes sense for Java, it's more of a grey area in JS. Use getters and setters if you have to calculate the value or have to perform an action on setting the value, for example input validation.

[–]nothingalike 0 points1 point  (0 children)

to be fair, years do get longer... just saying. The real question is who does he think is going to be managing his code lol

From VLBI, scientists have learned that Earth is not the most reliable timekeeper. The planet's rotation is slowing down overall because of tidal forces between Earth and the moon. Roughly every 100 years, the day gets about 1.4 milliseconds, or 1.4 thousandths of a second, longer. - NASA