Skip to main content

Book Summary 01 You don't Know JS by Kyle Simpson

What is JS?

  • JavaScript is a continuous practice: Whatever your level, you can keep deepening your understanding of the language.
  • JavaScript is multi-paradigm: JavaScript is a language that allows you to write procedural, object-oriented or functional code. You can make these choices on a line-by-line basis, instead of being forced into an all-or-nothing choice.
  • Backwards and backwards compatibility: JavaScript is backwards compatible, which means that code written in the past will continue to work in the future. However, it is not compatible with future versions, which means that code using new features may not work in older JavaScript engines. (BABEL)
  • JavaScript and the web: JavaScript runs in several environments, but browsers have strongly influenced its APIs and uses.
  • JavaScript supports several paradigms: The language supports procedural, object-oriented and functional code.
  • JavaScript and the web: Many features that resemble JavaScript, such as alert(..) and console.log(..), are not defined by JavaScript itself, but by the environment that runs the JavaScript engine.
  • JavaScript and specifications: The syntax and behavior of JavaScript are defined in the ECMAScript specification.
  • The TC39 technical committee manages the official language specification.
  1. TC39. Anyone, whether a TC39 member or not, is welcome to participate in these public discussions and proposal work processes.
  2. Web Compatibility: JavaScript has backwards compatibility, which means that code that is accepted as valid JavaScript will not become invalid in future versions of the language. This means you can write code in JavaScript with confidence, knowing that your code won't stop working unpredictably due to a browser update.
  3. Transpilation: As JavaScript is not compatible with future versions, developers need to take special measures to bridge this gap. For new incompatible syntaxes, the solution is transpilation. Transpilation is a term coined by the community to describe the use of a tool to convert a program's source code from one form to another (but always as textual source code).

Key Points

  • Each file is a separate program; this affects error handling and interactions between files.
  • Values ​​in JavaScript can be primitives or objects. Primitives include strings, numbers, booleans, null, undefined, and symbols. Objects are unordered collections of various values.
  • Variables in JavaScript must be declared before being used. There are three keywords for declaring variables: "var", "let" and "const".
  • Functions in JavaScript are values ​​that can be assigned and passed around. They can receive parameters and return values.
  • JavaScript has several mechanisms to allow comparison of values. The "===" operator is often used to check equality, but it does not check structural equality for objects, only identity equality.
  • Coercion in JavaScript means that a value of one type is converted to its respective representation in another type. This can cause confusion when used with comparison operators, particularly the "==" operator which is often criticized for its coercive behavior.

Determining the value type

  • The typeof operator can be used to determine the built-in type of a value, primitive or object.
  • typeof null returns "object" instead of "null".
  • Conversion from one type of value to another is called "coercion".

Functions

  • JavaScript functions are reusable procedures: they receive inputs and return outputs.
  • Functions can be declared using the "function" syntax or defined as an expression assigned to a variable.
  • Functions in JavaScript are object values ​​and therefore can be assigned and passed.
  • Functions can receive parameters and return values ​​using the "return" keyword.
  • Functions can be defined as properties on objects.
  • There are many varied forms for defining functions in JavaScript.