NodeJS by Example: Modern JS
This section is a crash course on the basic concepts of modern JavaScript that you'll see both in NodeJS and the browser. |
Variables are used to store data that can be used later in the program. In JavaScript, you can declare a variable using the `let` or `const` keywords |
|
Primitives refer to fundamental, immutable data types that are not objects. These include: |
|
Strings: A sequence of characters. |
|
Numbers: Represents numeric values, both integers and floating-point numbers. |
|
BigInt: Represents large integers that cannot be represented by the number type. |
|
Booleans: Represents a logical value, either true or false. |
|
Undefined: Represents a variable that has been declared but not assigned a value. |
|
Null: Represents an intentional absence of any object value. |
|
Symbols: Represents a unique and immutable value that may be used as an object property key. |
|
Functions are blocks of code that can be called to perform a specific task. In JavaScript, functions are first-class objects, which means they can be passed around like any other value. |
|
Arrow functions, a concise syntax for writing functions: |
|
IIFE (Immediately Invoked Function Expression) is a function that is executed immediately after it is created. |
|
Template Literals, string interpolation using backticks: |
|
Destructuring is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. |
|
Default parameters setting default values in functions: |
|
Rest and Spread Operators are two new operators introduced in ES6 that can be used to manipulate arrays and objects. |
|
Modularized code using import and export: |
|
Classes are a template for creating objects, providing initial values for properties and methods. |
|
Callbacks are functions that are passed as arguments to other functions and are executed after some operation has been completed. |
|
Promises are objects representing the eventual completion or failure of an asynchronous operation. They are used to handle asynchronous operations in JavaScript. |
|
Async/Await is a new way to write asynchronous code in JavaScript. It makes asynchronous code look and behave more like synchronous code. |
|
Promise.all is a method that takes an array of promises and returns a single promise that resolves when all of the promises in the array have resolved. |
|
Promise.allSettled is a method that takes an array of promises and returns a single promise that resolves when all of the promises in the array have settled (either resolved or rejected). |
|
Optional Chaining is a JavaScript feature that allows you to safely access nested properties of an object without worrying about whether the property exists or not. |
|
Nullish coalescing is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand. |
|
Dynamic Imports allow you to import modules only when they are needed. This can help reduce the initial load time of your application. |
|