[go: up one dir, main page]

0% found this document useful (0 votes)
21 views12 pages

Advance JS

The document outlines essential JavaScript concepts every developer should know, including closures, callback functions, promises, async/await, hoisting, temporal dead zone, event loop, strict vs loose equality, currying, and debouncing/throttling. Each concept is briefly explained with examples of their usage and importance in handling asynchronous operations and optimizing performance. The document serves as a quick reference guide for advanced JavaScript techniques.

Uploaded by

bimanmaity2023
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)
21 views12 pages

Advance JS

The document outlines essential JavaScript concepts every developer should know, including closures, callback functions, promises, async/await, hoisting, temporal dead zone, event loop, strict vs loose equality, currying, and debouncing/throttling. Each concept is briefly explained with examples of their usage and importance in handling asynchronous operations and optimizing performance. The document serves as a quick reference guide for advanced JavaScript techniques.

Uploaded by

bimanmaity2023
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/ 12

Advance Javascript

Snippets
EVERY DEVELOPERS MUST KNOW

LokeshkDev SWIPE
lk_webdev_247
Closures
A function remembers the variables from
its outer scope even after the outer
function has finished.

LokeshkDev SWIPE
lk_webdev_247
Callback Functions
A function passed as an argument and
executed later.

LokeshkDev SWIPE
lk_webdev_247
Promises‌
A Promise is used to handle asynchronous operations, like fetching data from
an API or reading a file.‌
👉 It promises to return a result in the future, either a success or a failure.‌

LokeshkDev‌ SWIPE
lk_webdev_247‌
Async/Await
async/await is a cleaner, easier
way to handle asynchronous async makes a function return a Promise.
operations, like fetching data — await pauses the function until the Promise
resolves or rejects.
without using .then() and
.catch() everywhere.

LokeshkDev SWIPE
lk_webdev_247
Hoisting‌
Hoisting is JavaScript’s default behavior of moving declarations to
the top of the current scope (function or global) before code runs.‌

✅ Only declarations are hoisted, not initializations.‌

LokeshkDev‌ SWIPE
lk_webdev_247‌
Temporal Dead Zone
(TDZ)
The time between when a variable is hoisted and when it is initialized.

This applies to variables declared with let and const

TDZ Timeline

LokeshkDev SWIPE
lk_webdev_247
Event Loop + Call Stack
JS handles sync (stack) and async (queue) code in a non-blocking way.
The Call Stack runs the code
The Event Loop decides when to run async tasks
The Task Queue holds the waiting callbacks

Task Queue
Call Stack
How it

Watches stack Event Loop

Holds async tasks Task Queue

LokeshkDev lk_webdev_247 SWIPE


== VS ===
== (Double Equals) — Loose Equality === (Triple Equals) — Strict Equality
Compares values only and converts Compares value and type, no type
types if needed (type coercion). conversion.

Always use === for safer, more predictable comparisons.

LokeshkDev SWIPE
lk_webdev_247
Currying
Currying turns a function with multiple arguments into a
chain of functions, each taking one argument at a time.

Normal Function Vs Currying Version


Takes all its arguments at once and First call: add(2) → returns a function
returns a result. Second call: That returned function is
called with 3

LokeshkDev lk_webdev_247 SWIPE


Debounce & Throttle
Used to optimize performance by controlling how often a
function runs — especially during rapid events like typing,
scrolling, or resizing.

Debounce delays function until Throttle limits execution to once


user stops typing/clicking. every X ms.

LokeshkDev lk_webdev_247 SWIPE


THANK YOU
SO MUCH!
Follow me on more
LokeshkDev lokesh-v-kumar

lk_webdev_247

You might also like