Please enable JavaScript.
Coggle requires JavaScript to display documents.
JS concepts (Event loop (Call stack (Stack of executing functions),…
JS concepts
Event loop
-
-
Web APIs
External functions: SetTimeout, Click, etc
How events are triggered in js. JS is async, the code is triggered and won't wait for the previous code to be triggered, but only one thing can be executed at the same time
-
-
-
Other concepts
Hoisting
-
-
-
Variables declared with let and const remain uninitialised at the beginning of execution. Variables declared with var are initialised with a value of undefined.
Functions expressions (var a = fun()) are hoisted but it's assignment to a function is not. Therefore, the intepreter throws a TypeError since it sees expression as a variable and not a function.
Closures
Scope or context that will be considered for the variable or function. A closure can access variables of the parent scope without these have been passed as parameters
Event propagation
Bubbling: Execution triggered, first on the child, then to parents
Capturing: Execution triggered first on the parent, then to the childs
-
Types
Reference types
Objects, are copied by their reference
-
-
-
Value types
-
-
-
-
-
-
Primitives, are copied by their value
DOM
With the HTML DOM, JavaScript can access and change all the elements of an HTML document
Document Object Model that let javascript to interact and modify the html elements. Nexo between JS and the Html
-
Paradigms
Functional Programming
-
-
Monad
Is like a functor, an object that can be flatMap/chain to extract value from the context (promise, stream, composed function) to be mapped, and then be returned again in context. Example: Observable, a promise (not exactly)
Lambda
Lambda calculus is a rules system to work with functions. Also called as the smallest programming language
-
Prototypes chain
Inheritance
-
Object composition
-
-
Object.assign(obj, props)
-
Class inheritance
In JS, Classes still being prototypes
Static
Makes a property of a class fully accesible from outside because now owns to that class instead of the prototype
-
*JS doesn't need classes to work with objects, JS has more freedom to create and use them.
Constructor
When a class extends another and you want to override the constructor, you must use super() to let the parent constructor build the object for THIS
Super
Super is used to not totally replace a method when doing overriding. You can use super.method() inside a method or super() inside the constructor
Prototype
-
-
When accessing a property inside an object, if it doesn't exist, js will look for it on the prototype, if isn't there, will look in the prototype of the prototype and goes on
Accessing prototypes
-
.prototype property is for types, and Object.getPrototypeOf() is for instances
Node
v8
JS engine (compiler, virtual machine)
JIT (just in time) compile: compiles and run, compiles and run...
-
-
JS runtime based on v8 engine (runtime: browser, node)