0% found this document useful (0 votes)
5 views

Master Advanced JavaScript Concepts for Interview Success

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Master Advanced JavaScript Concepts for Interview Success

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Save for later

ADVANCED
JAVASCRIPT
CONCEPTS FOR
INTERVIEW

@Tech_sanku
001

CALLBAKCS
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
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
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
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.
005

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.


006

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
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
007

SCOPE

var

const
008

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
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
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.
011
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
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
013
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
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.
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 ??

@Tech_sanku

You might also like