Advance Javascript Concepts
Advance Javascript Concepts
ADVANCED
JAVASCRIPT
CONCEPTS FOR
INTERVIEW
@subhajit-adhikary
001
CALLBAKCS
A JavaScript callback is a function which is to be executed
after another function has finished execution.
Output
@subhajit-adhikary
002
PROMISES
A promise is an object that will produce a single value sometime
in the future. If the promise is successful, it will produce a
resolved value, but if something goes wrong then it will produce
a reason why the promise failed.
Simply said:- It behaves very much similar to real life promises.
Output
@subhajit-adhikary
003
ASYNC/AWAIT
Async/Await makes it easier to write promises. The keyword
'async' before a function makes the function return a
promise, always. And the keyword await is used inside async
functions, which makes the program wait until the Promise
resolves.
Output
@subhajit-adhikary
004
STRICT MODE
The "use strict" directive enables JavaScript's strict mode.
This was introduced in ECMAScript 5. It enforces stricter
parsing and error handling on the code at runtime. It also
helps you write cleaner code and catch errors and bugs that
might otherwise go unnoticed.
@subhajit-adhikary
005
@subhajit-adhikary
006
Output
@subhajit-adhikary
007
SCOPE
The scope is the current context of execution in which values and expressions are
"visible".
JavaScript variables have 3 types of scope:
Block scope:- Variables declared inside a { } block cannot be accessed from outside
the block. let and const have block scope.
Function scope:- Variables defined inside a function are not accessible (visible) from
outside the function. let, const and var have function scope.
Global scope:- Variables declared Globally (outside any function) have Global Scope.
let, const and var have global scope.
let
@subhajit-adhikary
007
SCOPE
var
const
@subhajit-adhikary
008
CLOSURES
A closure is the combination of a function bundled together (enclosed)
with references to its surrounding state (the lexical environment).
Output
@subhajit-adhikary
009
HOISTING
A javascript mechanism where variables with var and function
declarations are moved to the top of their scope before code execution.
function declarations are properly hoisted (not arrow functions)
var is hoisted.
Output
@subhajit-adhikary
010
IIFE (Immediately Invoked
Functional Expressions)
An IIFE is a function that is called immediately after it is defined.
Use cases of IIFE:-
Avoid polluting the global namespace.
Execute async/await functions.
Provides encapsulation, allowing you to create private scopes for
variables and functions.
@subhajit-adhikary
011
CURRYING
It involves breaking down a function that takes multiple arguments into
a series of functions that take one argument each.
Output
@subhajit-adhikary
012
DEBOUNCING
Debouncing is a strategy used to improve the performance of a feature
by controlling the time at which a function should be executed.
Simple words:- It delays the execution of your code until the user stops
performing a certain action for a specified amount of time. It is a
practice used to improve browser performance.
Js code
HTML code
@subhajit-adhikary
013
THROTTLING
Throttling is a mechanism that allows a function execution for a limited
number of times after that it will block its execution.
Js code
HTML code
@subhajit-adhikary
014
POLYFILLS
Polyfill is a way of providing futuristic API not available in browser.
We might need to do the native prototype modifications, so that we
can get a feature/API.
There might be situations when we have a method not supported for
specific browsers, in such cases we can use polyfills.
@subhajit-adhikary
Save for later
KEEP LEARNING
PS:- Remember, these tips are just the start of
your advanced journey with Javascript.
There's always more to learn and explore, so
keep coding and keep growing!
@subhajit-adhikary