33 JavaScript Concepts Every Developer Should Know 🤓️💯️

Reference :

33-js-concepts by Leonardo Maldonado on Github


1. Call stack, Heap, Queue, Execution Context, Event Loop

2. Data Types

3. Value Types and Reference Types

4. Coercion (Type Casting)

5. == vs === vs typeof

== === typeof
Checks if the values being compared are equal, performing type coercion if necessary.
Performs a loose comparison
Checks if the values being compared are equal and of the same type, without performing any type coercion.
Performs a strict comparison
Determine the type of a value or expression
Returns boolean value Returns boolean value Returns a string representing the type of the operand.
Example :
4 == '4' // true
Example :
4 === '4' // false
Example :
typeof 'hi' // 'string'

6. Scope

Global scope Function scope Block scope
Variables declared outside of any functions or blocks. Variables declared within a function Variables declared within block (defined by curly braces)
accessed from anywhere within the code, including other functions and blocks. only accessible within that function and any nested functions inside it only accessible within the block.

7. Expression vs Statement

Expression Statements
Expressions evaluates to a single value Statements are the instructions to perform task
Example :2+3*5 will evaluates to 17 Example :if (true) console.log("hi")

8. IIFE, Modules and Namespaces

9. Message Queue and Event Loop

10. setTimeout, setInterval and requestAnimationFrame

11. JavaScript Engines

12. Bitwise Operators

13. DOM

14. Factory functions

14. this, call(), apply(), bind()

this

bind

call

apply

arguments is a collection of arguments that are being passed to the function

function fn() {
  console.log(arguments);
}
fn(1, 2, 3); // [Arguments] { '0': 1, '1': 2, '2': 3 }

16. new, constructor, instanceof and Instances

17. Prototype Inheritance and Prototype Chain

18. Object.create and Object.assign

19. map, reduce, filter, forEach

map

reduce

filter

forEach

20. Pure Functions, Side Effects, State Mutation and Event Propagation

Deterministic Function

Side effect

Pure Functions

State Mutation

Event Propagation

21. Closures

function x() {
  const a = 10;
  return function () {
    console.log(a);
  };
}
const z = x();
z(); // Output : 10

22. High Order Functions

//takes function as a parameter
array.map(() => {...});
//or
setTimeout(() = {...});
//returns a function
function x() {
  return function () {
    console.log("hello");
  };
}

23. Recursion

const countDown = (num) => {
  if (num == 0) return;

  console.log(num);

  countDown(num - 1);
};

countDown(5);

// Output : 5 4 3 2 1

24. Collections and Generators

Collections

Generators

function* simpleGenerator() {
  console.log("before yield 1");
  yield 1;
  console.log("before yield 2");
  yield 2;
  console.log("after yield 2");
}

const obj = simpleGenerator();
console.log(obj.next()); // Output : before yield 1 \n {value: 1, done: false}
console.log(obj.next()); // Output : before yield 2 \n {value: 2, done: false}
console.log(obj.next()); // Output : after yield 2 \n {value: undefined, done: true}

25. Promises

let prom = new Promise((resolve, reject) => {
  let flag = true;
  if (flag) {
    resolve("success");
  } else {
    reject("Failed");
  }
});

prom
  .then((message) => {
    console.log("✔️", message);
  })
  .catch((message) => {
    console.log("❌", message);
  });```