DEV Community

Discussion on: Coding Conventions for Writing JavaScript

Collapse
 
mateiadrielrafael profile image
Matei Adriel • Edited

What is this stuff?!?!

First of all, all js engines can work with semicolonless code, this isn't a convention and I know a lot of people who do not use them.

Same for the 2 indentation one, I know a lot of people who prefer 4 spaces instead of 2.

The dollar sign at the end is a convention for all observable values in the rxjs community, so ir shouldn't be simply avoided.

Also, you cannot even run code with the variable name 123somethimg because variable mames cannot start with numbers.

Not trying to be rude but how am I supposed to belive an article written by a guy who starts loops at 1 and ends them when the counter <= the end

Collapse
 
devdufutur profile image
Rudy Nappée

You certainly misreaded, he says don't use a $ as a prefix not as a suffix.

And even if you can use semiconlonless code, it shouldn't mean you have to. Semicolons improve readability of your code. Look at default configurations of JS code formatters like prettier...

(1) for (let i = 0; i < arr.length; i++)

is strictly equivalent to

(2) for (let i = 1; i <= arr.length; i++)

Even if I don't use this second form, some could argue it's more human readable (humans starts counting at 1 as far as i know).

Collapse
 
mateiadrielrafael profile image
Matei Adriel • Edited

A convention is something people decided is the best way to do somrthing. Since a lot of people don't use seimcolons it just means it's not a convention

Also, 99% of people start loops at 0, so why do it the other way around in a post about "conventions"