Null vs Undefined
Most languages have data type for variables. JS also has, but at the time of declaration, there is no type decided. loose equality(==) - performs type conversion (converts the operands to the same type before making the comparison) ('5' == 5) strict equality(===) - compares the value and also checks the data type Function vs Block Scope
HOISITNG - A process which is happening behind the scene, internally it is bringing the declarations on top (not the assignment) const - cannot be reassigned let + const - cannot be redeclarable, var can be The concept of "block scope" refers to the visibility domain of variables declared within such a code block. In JS, a variable declared within a code block is visible only within that block and not outside of it. ASI (Automatic Semicolon Insertion)
function rest() { return ;- undefined because js compiler adds a semicolon { a : 5 } |
Rest & Spread operator (ES6)
function restex(...elems){ console.log(elems)} let max = Math.max(...arr) Infinity & -Infinity
You got -Infinity or Infinity when a numeric value exceeds the range of 64-bit format. NaN (Not a Number)
console.log(NaN === NaN) - false - strict equality or non-equality, it is not going to match with NaN because there is always a unique value for NaN. Arrow functions
Arrow functions offer a concise syntax for writing anonymous functions, leading to shorter and more readable code. if you have one parameter you can avoid writing paranthesis IIFE – It is a function which gets called automatically (function())() Currying
|
Closure
function outer() { function inner() { console.log("inner called..") }} Iterables & Iterators (ES6)
New mechanism to iterate or traverse through data structures. console.log(itr.next()) = {value: 4, status: false} Generators
Generators help you to pause & resume the code. Normally when you write a function, it returns a single value -> generators are kind of function which returns multiple values in phases next() - it moves the function pointer to the next line from last suspended yield. Errors
When the program faces errors, even after validation, it should handle it & notify the user with proper error details. |
Cheatography
https://cheatography.com
Fundamental JS Cheat Sheet (DRAFT) by teog29
fundamental js course
This is a draft cheat sheet. It is a work in progress and is not finished yet.