[go: up one dir, main page]

0% found this document useful (0 votes)
10 views17 pages

Javascript

Uploaded by

xoyes63597
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views17 pages

Javascript

Uploaded by

xoyes63597
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Top 20 JavaScript

Concepts You Must Learn

@ sanuj bansal
Hoisting
Hoisting is JavaScript's behavior of moving variable and
function declarations to the top of their scope before
execution.

Key Points:
Works with var (hoisted but undefined) and function
declarations (hoisted with definition).
let and const are hoisted but remain in the Temporal Dead
Zone (TDZ).

@ sanuj bansal
The this Keyword
This refers to the object it belongs to, but its value depends on
how a function is called.

Key Points:

In a method: refers to the object.


In a function: refers to undefined in strict mode, or window
in non-strict mode.
In arrow functions: inherits this from the surrounding scope

@ sanuj bansal
Promises
Promises handle asynchronous operations and represent a
value that may be available now, later, or never.

Key Points:

States: Pending, Fulfilled, Rejected.


Methods: .then(), .catch(), .finally().

@ sanuj bansal
Async/Await
A syntactic sugar over promises, making asynchronous code
look synchronous.

Key Points:

Use await inside async functions.


Easier error handling with try...catch.

@ sanuj bansal
Event Loop
The mechanism that handles asynchronous callbacks in
JavaScript.

Key Points:

JS is single-threaded.
Event loop checks the call stack and task queue.

@ sanuj bansal
Call Stack & Execution
Context

JavaScript uses the call stack to manage function execution,


and each function runs inside its own execution context.

Key Points:

Call Stack: LIFO (Last In, First Out).


Execution Context has three phases: Creation, Execution,
and Deletion.
The Global Execution Context is created before any code
runs.

@ sanuj bansal
Prototypes & Inheritance

Every JavaScript object has a prototype from which it can


inherit properties and methods.

Key Points:
Prototype chain enables inheritance.
Object.create() can create objects with a specific prototype.

@ sanuj bansal
Scope (Global, Function,
Block)

Scope determines where variables can be accessed.

Key Points:

Global Scope: accessible anywhere.


Function Scope: variables declared inside functions are
local.
Block Scope: let and const are limited to {} blocks

@ sanuj bansal
Lexical Scope

Lexical scope means inner functions can access variables from


their parent functions.

Key Points:
Scope is determined by where code is written, not where
it's called.

@ sanuj bansal
Destructuring
Extract values from arrays or objects into variables in a cleaner
way.

Key Points:
Works with arrays, objects, and nested structures.

@ sanuj bansal
Spread & Rest Operators
... is used to expand or collect elements.

Key Points:
Spread: expand arrays/objects.
Rest: collect remaining values into a single array or objec

@ sanuj bansal
Variables (let, const, var)
JavaScript variables differ in scoping and mutability.

Key Points:
var: function-scoped, hoisted.
let: block-scoped, can be reassigned.
const: block-scoped, cannot be reassigned

@ sanuj bansal
Closures
A closure is created when a function remembers its lexical
scope even when executed outside its original scope.

Key Points:
Useful for data privacy and state persistence

@ sanuj bansal
Memory Management &
Garbage Collection

JavaScript automatically allocates and frees memory when


variables are no longer used.

Key Points:
Uses reference counting and mark-and-sweep algorithm.
Memory leaks happen if references aren’t released

@ sanuj bansal
Debounce & Throttle
Techniques to control how often a function is executed.

Key Points:
Debounce: runs after a pause in events.
Throttle: runs at fixed intervals

@ sanuj bansal
Follow For More
Such Content !

Sanuj Bansal
Senior Developer

You might also like