History

History


Beginning

JavaScript History and Evolution

  • 1995: Brendan Eich created "Mocha" in 10 days for Netscape Navigator.
  • 1996: Renamed to "LiveScript" and then "JavaScript" for marketing.
  • 1997: Standardized as ECMAScript (ES1) by ECMA.
  • ES5 (2009) and ES6/ES2015 introduced major updates, with ES6 marking the start of annual release cycles.

Backward Compatibility (Don’t break the web)

  • JavaScript engines must support the earliest releases to avoid "breaking the web."
  • ECMAScript builds on existing features rather than introducing breaking changes (e.g., class is syntactic sugar).
  • ECMAScript doesn't have entirely new versions, but rather builds upon the existing language with new features released annually
  • It means that the TC39 committee can’t have ground-breaking changes and the newer changes are only built on top of existing ones. One such example is with class as it is not native
TC39 Proposals is a place to suggest new features to the language
TC39 Proposals is a place to suggest new features to the language

How to use Modern JavaScript Today Updated?

caniuse.com can be used to see browser support
  • Forward compatibility isn’t possible.
  • To use modern features:
      1. In Development use updated browsers;
      1. Production often uses Babel for transpilation and polyfills.
  • ECMAScript proposals go through 4 stages before becoming part of the specification. Stage 3 features are often implemented in browsers as ESNext.

Activating Strict Mode

  • It is not a keyword but a string “use strict” that is added on top of our JavaScript files, the reason is that only newer browsers can support it and older browser will ignore the string
  • It activates the so-called Strict Mode Operating Context
  • In strict mode assigning value to a undeclared variable will throw error, which otherwise gets added to the global variable (document or window). This prevents from accidental globals
  • The value of this changes from window to undefined in strict mode
'use strict'; var theVal = 0; thVal = 1; // Will throw error in strict mode if (theVal > 0){ console.log("Hello!"); }
  • It prevents use of variable names that might become part of the language in the future like interface or even let
"use strict"; var let = 1; // Runs without strict mode
  • We can’t delete values in strict mode
const framework = { name: "Next.js", age: 12 } delete framework.name // Not allowed
  • The use of eval won’t leak out variables. The eval is a function used to run some JavaScript inside a string
"use strict"; eval("var age = 14;") console.log(age); // Not allowed