xuset / tab-elect

Leader election for browser tabs and web workers
MIT License
13 stars 2 forks source link

Why is your code without semicolons? #3

Closed ghazpar closed 7 years ago

ghazpar commented 7 years ago

I am looking with interest at your code, but it is not valid javascript syntax; it does not execute as is. Am I expected to add all of the missing semicolons??? What is the point?

xuset commented 7 years ago

Hi @ghazpar! Semicolons are not required for valid javascript, and the code actually will run as-is in the browser thanks to Automatic Semicolon Insertion. Since semicolons aren't required, the use of them turn mainly into a style preference.

It's just my preference, but why waste keystrokes on unnecessary semicolons 😄 The awesome people over at standardjs have the same idea too which this project uses.

Hope this helps!

ghazpar commented 7 years ago

Well the code is not running for me in chrome. I will try again...

xuset commented 7 years ago

Any stack traces or error messages printed to the console would definitely be helpful in resolving the issue

ghazpar commented 7 years ago

Sorry, my mistake. I misinterpreted the error messages, thinking it was linked to the missing semicolons (I had noticed that semicolons were sometime optional, but never measured the extent of it).

My problem was linked to dependancies; I was assuming that tab-elect was standalone. You may want to consider adding them to your documentation!

BTW, I disagree that leaving out semicolons is a good idea. I think js is horrible enough, no need to make it worse by adding ambiguities.

xuset commented 7 years ago

I'll update the README to reflect this. Thanks for the suggestion!