Skip to content

SKindij/JavaScript-Reference-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

254 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

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

  • ๐Ÿ“– Basics:
    โ€‚ โ–บ obj literals โ–บ constructor func โ–บ classes โ–บ this โ–บ prototype chain โ–บ destructuring
  • ๐Ÿ“– Properties:
    โ€‚ โ–บ access โ–บ assignment โ–บ descriptors โ–บ computed prop
  • ๐Ÿ“– Methods:
    โ€‚ โ–บ definitions โ–บ this keyword โ–บ chaining
  • ๐Ÿ“– "Collection" objects
    โ€‚ โ–บ Map โ–บ Set
  • OOP object oriented programming in JS
    • ๐Ÿ“– Inheritance:
      โ€‚ โ–บ patterns โ–บ obj composition
    • ๐Ÿ“– Encapsulation:
      โ€‚ โ–บ getters & setters โ–บ private variables โ–บ closure func
    • ๐Ÿ“– Polymorphism:
      โ€‚ โ–บ overriding โ–บ overloading โ–บ dynamic dispatch

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();

About

topic ๐Ÿฆง a basic set of JavaScript knowledge

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors