JavaScript learning summary


Recently, I have been using JavaScript for front-end and back-end development (the back-end uses the Express framework), which is a very interesting programming language. Discovery during exploration MDN document (can choose Chinese) is a good learning material, so start reading and make a simple summary. At the end of the article, some links are attached to help you learn JS/ES/Express.

Introduction to JavaScript

JavaScript (JS) is a lightweight, interpretive or just in time programming language with function priority. Although it is famous as a scripting language for developing Web pages, it is also used in many non browser environments, such as node JS, Apache CouchDB and Adobe Acrobat. JavaScript is a dynamic scripting language based on prototype programming and multi paradigm, and supports object-oriented, imperative and declarative (such as functional programming).

What is ECMAScript

The standard for JavaScript is ECMAScript (ES). As of 2012, all modern browsers fully support Es5 1. The old version of browser supports at least ES3 standard. In 2015, ECMA International released the sixth edition, officially called ECMAScript 2015, which is usually called ECMAScript 6 or ES6. Since then, ECMAScript has issued a new standard once a year. This document currently covers the latest ECMAScript draft, ECMAScript 2020.

Node. What is JS

Node.js is an open source and cross platform JavaScript runtime environment that runs the V8 JavaScript engine (Google Chrome kernel) outside the browser. Front end developers who write JavaScript for browsers can now write server-side code in addition to client-side code.
Node.js applications run in a single process without creating a new thread for each request. Its standard library provides a set of asynchronous I/O native functions (to prevent JavaScript code from being blocked). When node JS when performing I/O operations (such as reading from the network, accessing the database or file system), node JS will resume the operation when the response returns, instead of blocking the thread and wasting CPU cycle waiting.
Node. The package manager npm of JS is the largest open source library ecosystem in the world.

What is Express

Express is a flexible node that maintains a minimum size JS Web application development framework provides a set of powerful functions for Web and mobile applications.



- var
- let: block-scoped
- const: block-scoped, read-only named constant


- one line: //
- multi-line: 
/* ...

Data types

  • 7 primitives:
    Boolean, Number, BigInt, String, Symbol (ES6), null, undefined
  • Object

Converting strings to numbers:

  • parseInt()
  • parseFloat()
  • + str


parseInt('101', 2) // 5
(+'1.1') + (+'1.1') // 2.2


  • Fixed values, not variables.
  • Types:
    Array, Boolean, Floating-point, Number, Object, RegExp, String

Function hoisting

Only function declarations are hoisted, but not function expressions.


/* Function declaration */
foo(); // "bar"
function foo() {

/* Function expression */
baz(); // TypeError: baz is not a function
var baz = function() {

Control Flow and Error Handling

Conditional statements

if (condition_1) {
} else if (condition_2) {
} else {

Falsy values:

  • false
  • undefined
  • null
  • 0
  • NaN
  • Empty string ("")

Switch statements

switch (expression) {
  case label_1:
  case label_2:

Exception handling statements

  • throw
  • try...catch...finally


function f() {
  try {
    throw 'bogus';
  } catch(e) {
    return true;    // this return statement is suspended
                    // until finally block has completed
    console.log(2); // not reachable
  } finally {
    return false;   // overwrites the previous "return"
    console.log(4); // not reachable
  // "return false" is executed now
  console.log(5);   // not reachable
console.log(f()); // 0, 1, 3, false
function f() {
  try {
    throw 'bogus';
  } catch(e) {
    console.log('caught inner "bogus"');
    throw e; // this throw statement is suspended until
             // finally block has completed
  } finally {
    return false; // overwrites the previous "throw"
  // "return false" is executed now

try {
} catch(e) {
  // this is never reached!
  // while f() executes, the `finally` block returns false,
  // which overwrites the `throw` inside the above `catch`
  console.log('caught outer "bogus"');

// caught inner "bogus"
// false

Error objects

function doSomethingErrorProne() {
  if (ourCodeMakesAMistake()) {
    throw (new Error('The message'));
  } else {
try {
} catch (e) {               // NOW, we actually use `console.error()`
  console.error(;    // logs 'Error'
  console.error(e.message); // logs 'The message', or a JavaScript error message

Loops and Iteration



MDN - JavaScript Guide

Useful Learning Resources

Basic JS:

Use OO with JS:


Tags: Javascript Programming ECMAScript

Posted by wwfc_barmy_army on Sun, 01 May 2022 09:06:59 +0300