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

Advance JavaScript Concept.

The document outlines advanced JavaScript concepts useful for interviews, including callbacks, promises, async/await, strict mode, higher-order functions, and scope. It also covers closures, hoisting, IIFE, currying, debouncing, throttling, and polyfills, providing simple explanations and use cases for each. The content emphasizes continuous learning and improvement in JavaScript skills.
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)
3 views17 pages

Advance JavaScript Concept.

The document outlines advanced JavaScript concepts useful for interviews, including callbacks, promises, async/await, strict mode, higher-order functions, and scope. It also covers closures, hoisting, IIFE, currying, debouncing, throttling, and polyfills, providing simple explanations and use cases for each. The content emphasizes continuous learning and improvement in JavaScript skills.
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

Save for later

ADVANCED
JAVASCRIPT
CONCEPTS FOR
INTERVIEW

@MohitDecodes
CALLBACK
A JavaScript callback is a function which is to be executed
after another function has finished execution.

Simply said:- Any function that is


passed as an argument to another
function so that it can be executed
in that other function is called as a
callback function. This results in
callback hell.

Output
PROMISE
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
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
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.
HIGHER ORDER FUNCTIONS
Functions can be assigned to variables in the same way that
strings or arrays can. They can be passed into other
functions as parameters or returned from them as well.

Simple words:- It is a function that accepts functions as


parameters and/or returns a function.

Eg:- map, filter, reduce, some, every, forEach, sort etc.


CALL, APPLY, BIND
Call is a function that helps you change the context of the invoking function. In
layperson's terms, it helps you replace the value of this inside a function with
whatever value you want.

Apply is very similar to the call


function. The only difference is
that in apply you can pass an
array as an argument list.

Bind is a function that helps you


create another function that you
can execute later with the new
context of this that is provided.

Output
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
SCOPE

var

const
CLOSURES
A closure is the combination of a function bundled together (enclosed)
with references to its surrounding state (the lexical environment).

Simple words:- A closure gives you access to an outer function's


variables and functions from an inner function.

Output
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
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.
CURRYING
It involves breaking down a function that takes multiple arguments into
a series of functions that take one argument each.

Simple words:- This creates a chain of functions, where each function


returns another function until the final result is achieved.

Output
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
THROTTLING
Throttling is a mechanism that allows a function execution for a limited
number of times after that it will block its execution.

Simple words:- It limits the execution of your code to once in every


specified time interval. It is a practice used to improve browser
performance.

Js code

HTML code
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.
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!

Save this post for future use


Was this helpful ??

@MohitDecodes

You might also like