Welcome to the Linux Foundation Forum!

Why does the course teach bad coding practices?


Throughout the entire course no semi-colons are used in the code to end the line. Anyone that have ever worked with JS for a while have run into weird bugs, if they don't use semi-colons.

And the examples are horrible:

'use strict'

const upper = (str) => {
  if (typeof str === 'symbol') str = str.toString()
  str += ''
  return str.toUpperCase()

module.exports = { upper: upper }

Why have ES-Lint not been run on the examples? It seams the authors wants to deliberately write badly formatted and unreadable code.


  • k0dard
    k0dard Posts: 115

    Although the use of semicolons in javascript seems to be an opinionated subject it is true that bugs may appear due to absence of semicolons (for example https://stackoverflow.com/questions/33644285/javascript-and-semicolon)
    I did also some courses on MongoDB university and they didn't put semicolons either...
    Can someone explain - if already there is a risk of not putting semicolons, why do some people prefer not putting them ?

  • mje
    mje Posts: 12

    From my understanding, the intention have always been that humans should write semi-colons, but since JS is a scripting language that were designed to work in a browser, where loading time is important, clever optimizations were added to the language to make it shorter, and hence improve loading time. Much of of the JS syntax have this design. Just look at the fat arrow function syntax.

    So what happened was that to save a compilation step (minifacition), some people learned to write JS in the minimalistic form. Ie. much harder to read. The skills required to understand how the JS compiler works and hence when a semi-colon is absolutely required belongs to the experts.

    Languages that uses semi-colons are easier to read, as a newline without semi-colon is always a continuation of the previous line.

    Sort of a similar thing happened to YAML. It wasn't intended to be written by humans (from my understanding), but it is learnable, so again, to save a compile step, people just wrote it.

  • davidmarkclements

    the code uses standard linting: https://github.com/standard/standard

    Semi-colons have been debated ferociously in many epic flamewars over the past umpteen years, we won't be doing that again here.

This discussion has been closed.


Upcoming Training