Master Advanced JavaScript Concepts for Interview Success
Master Advanced JavaScript Concepts for Interview Success
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.
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
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).
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.
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.
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!
@Tech_sanku