Why is JavaScript so Bizarre? (Sloppy mode vs Strict mode)

Apparently, JavaScript wasn’t created to be what some people refer to as a “serious programming language”. Even so, JavaScript has now become the most popular programming language in the world.

However, it has some serious peculiarities in comparison to other programming languages, some of which have been remedied but not all of them, and I’m not joking when I tell you that JavaScript has a “sloppy mode” and a “strict mode”.

Sloppy mode is JavaScript’s default behaviour, which is extremely dodgy for anyone coming from another programming background such as C++. A few examples of the kind of the mistakes sloppy mode can be blamed for (but which don’t throw errors) are listed below:

  1. Spelling mistakes resulting in the creation of undeclared variables.
  2. Function parameters being allowed to be duplicated.
  3. Overriding the value of reserved keywords.

Strict mode fixes some of the issues, but it’s not a perfect solution. Sloppy mode is still the default mode, and aspects of sloppy mode and strict mode can even be mixed together, and as I've demonstrated in the video, even when in strict mode, it's still possible to assign a value to a variable before having declared it, which is made possible thanks to JavaScript's so-called hoisting.