Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "semi"


JavaScript Best Practices

  • To make correct use of it, you need to follow some best practices to avoid any problems that might come about otherwise.
  • I share some of the best practices you really should be following when writing JavaScript code.
  • The reason is that it does not have function-level scope because we forgot to put var keyword before it unlike firstName variable.
  • Experienced JavaScript developers know pretty well about JavaScript’s automatic semi-colon insertion problem and avoid it.
  • With both ways, all child classes will be able to use the display method but there is important difference between the two.
  • The reason why this is good practice is that, in IE, with extra comma at the last property, we do not get expected results sometimes ( ExtJS developers must have learned this).

save | comments | report | share on


Why you should use semicolons in spite of ASI

  • You got me yeah, write less sure, but what about context switching, you want to learn another language, I don't know, say Java, C++, C, Rust, PHP among others, these languages do not have ASI and you will need to add semis.
  • The last case, I have worked in 2 large companies, both use semi's as lint rules that say use them, so regardless of your preference, you are going to be using them.
  • I feel there is a stronger case to enforce them to prevent errors during authoring and if a company told me otherwise I would fight hard to explain the cognitive load of remembering when and where to add semicolons in order for the parser to not mistake a () as a function call.

save | comments | report | share on