Skip to content

SKindij/JavaScript-Reference-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript-reference-book

topic 🦧 a basic set of JavaScript knowledge

📚 Syntax

  • 📖 Variables:
      ► declaration ► assignment ► var ► let & const ► naming
  • 📖 Data types:
      ► strings ► numbers ► booleans ► null ► undefined ► objects ► symbols ► BigInt
  • 📖 Variable scope
      ► global ► local ► function ► code block
  • 📖 Additionally:
      ► hoisting ► Lexical scope
  • 📖 Operators:
      ► arithmetic ► comparison ► logical ► bitwise
  • 📖 Literals:
      ► string ► numeric ► boolean ► object

📚 Control flow

  • 📖 Conditionals:
      ► if/else ► switch ► ternary operator
  • 📖 Loops:
      ► for ► while ► do..while
  • 📖 Controls:
      ► break ► continue ► return
  • 📖 Exception handling:
      ► try..catch ► throw ► finally

Console API reference

  • console.log( object [, object, ...] ); >> Prints a message to the Console.
  • console.dir( {object} ); >> Prints a JSON representation of the specified object.
  • console.dirxml( document ); >> Prints an XML representation of the descendants of node.
  • console.group( 'label' ); >> Visually groups messages together.
    • console.info( 'log-1' );
    • console.info( 'log-n' );
    • console.groupEnd( 'label' );
  • console.count( [label] ); >> Writes the number of times that count() has been invoked with the same label.
  • console.table( array [, columns] ); >> Logs an array of objects as a table.
  • console.warn( object [, object, ...] ); >> Prints a warning to the Console.
  • console.assert( expression, {object} ); >> Writes an error to the console when expression evaluates to false.
  • console.error( object [, object, ...] ); >> Prints object to the Console, formats it as an error, and includes a stack trace.
  • console.clear(); >> Clears the console.

📚 Arrays

  • 📖 Basics:
      ► declaration ► initialization ► accessing
  • 📖 Methods that do not change initial array
    • array search methods
      • ► .indexOf ► .lastIndexOf ► .find ► .findIndex
      • ► .includes ► .some ► .every
    • array conversion methods
      • ► .toString ► .join
      • ► .concat ► .toLocaleString
    • array iteration methods
      • ► .map ► .reduce ► .reduceRight ► .filter
    • array transformation methods
      • ► ► .slice ► .flat ► .flatMap
  • 📖 Methods that change initial array:
    • array mutator methods
      • ► .push ► .unshift ► .pop ► .shift
      • ► .splice ► .copyWithin ► .fill
    • array sorting methods
      • ► .reverse ► .sort
  • 📖 Other methods:
    • ► Array.isArray
    • ► .forEach
  • 📖 Destructuring:\
    • ► syntax ► swapping var
  • How to copy an array?

📚 Objects


ECMAScript (or ES) specification.

That is set of rules and guidelines that language must follow in order to be considered compliant with this specification.

2009-2011 ES5 standard

  • Strict mode ('use strict') provides more detailed error checking in code and facilitates debugging.
  • you cannot use variables without a declaration;
  • function parameters cannot have the same names;
  • this will not reference a global object by default;
  • does not allow using the with construction in the code;
  • cleans up variables created with eval;
  • Object.keys(), filter(), map(), reduce(),
  • JSON support.

2015 ES6 version

  • let and const variables appeared, replacing outdated var;
  • arrow functions that preserve context;
  • syntactic sugar in the form of classes;
  • default function arguments;
  • promises;
  • destruction of objects;
  • ES-modules
  • keyword export is used for export;
  • keywordimport is used for import;
  • they can be perceived as parts of constructor from which program is assembled;
  • modules are always "use strict" - this is not window, but undefined.

ES2016:

  • destruction of arrays;
  • includes;
  • exponentiation through **;

ES2017:

  • Object.values,
  • Object.entries;
  • async/await;

ES2018:

  • finally for promises;
  • update in regular expressions;
  • spread operator for objects;

ES2019:

  • flat, flatMap for arrays;
  • fromEntries for objects;
  • queueMicrotask() for event-loop

ES2020:

  • BigInt;
  • Globalthis;
  • ??;

📚 Functions

  • 📖 Basics:
      ► declaration ► expression ► arrow func ► anonymous func
  • 📖 Parameters @ Arguments:
      ► positional ► default ► rest
      ► arg object ► destructuring ► spreading arg
  • 📖 Return:
      ► statement ► values ► implicit
  • 📖 Recursion:
      ► recursive func ► base cases
  • 📖 Closure:
      ► lexical scope ► closure func
  • 📖 Callbacks:
      ► higher-order func ► callback func

📚 Asynchronous

  • 📖 Event loop:
    • call stack
        ► any function that's called synchronously
    • microtasks
        ► process.nextTick ► Promise.then ► async function
    • macrotasks
        ► setTimeout(c, 0) ► setImmediate ► setTimeout(c, n) ► setInterval
  • 📖 Promises:
      ► syntax ► chaining ► promise.all ► error handling
  • 📖 Async/await:
      ► syntax ► error handling ► async generators

📚 Browser API

  • 📖 DOM-BOM
      ► DOM manipulation ► Web Storage ► events
  • 📖 Web API
      ► XMLHttpRequest ► fetch API
  • 📖 Web Workers
      ►

📚 Regular Expressions

  ► regExp syntax ► literals ► constructor

  • 📖 RegExp methods:
      ► test() ► match() ► search() ► replace() ► split() ► exec()
  • 📖 RegExp patterns:
      ► char classes ► quantifiers ► alternation ► grouping ► flags
  • 📖 Meta-characters:
      ► dot, caret, dollar ► brackets

Statement is a separate command in code that performs a specific action.

 In JavaScript, all instructions can be divided into several categories:

  1. declaration of values

let and const never go out of scope where they were defined and are always initialized where specified;

  1. management of execution flow
   if (condition) { "perform certain actions";
   } else { "an alternative scenario takes place"; }

   switch (expression) {
     case value1: 
       statement1
       break;
     case value2: 
       statement2
       break;
     default: 
       statements }
  1. iterations
    while (condition) { statement };

    do { statement } while (condition);

   for (initialization; condition; afterthought) { statement };
  1. functions
  2. others ( debugger, import, export );

Expression is code that returns any value when executed.

 There are 4 ways to execute something in JS:

  1. by calling the function;
  2. by calling the method of the object (the function is stored in the object);
  3. through the constructor function (create new objects of the same type);
  4. indirect function call via .call() or .apply();

Releases

No releases published

Packages

No packages published