JOIN US & LEARN
WEB DEVELOPMENT
The Quick Refresher
JAVASCRIPT INTERVIEW
QUESTION + ANSWER
Var, Let, Const
Closure
Unshift() & pop()
0, Null, Undefined
Anonymous Function
Learn all in one place
Unescape() & escape()
Event Bubbling
New Operator
@developers_community._ | @gowsami.devJOIN US & LEARN
BR SAVE THIS POST WEB DEVELOPMENT
Q1 What is difference between VAR, LET & CONST?
“The difference between var and let is that var is
function scoped while let is block-scoped ”
YES VES YES
YES VES NO
NO YES YES
const
@developers_community._ X | @gowsami.devQ2 What is Closure in JavaScript?
Closure in JavaScript means an inner function have access to
the variables that are defined in the outer function. Whenever
we are declaring a function inside another function we are
actually creating closures.
Closure Example ->
Complete overview -
The Global Scope has access only to
> dlobalvariable. It doesn't know about
variables inside outerFunction or the
closure inside outerFunction.
outerFunction has access to
outerFunctionVar and globalVar
(the string “global scope”). It
doesn't know anything about
what's inside of its closure, Inner-
Function.
Our closure (innerFunction) has
access to outerFunction and all of
its variables, as well as everything in
the global scope.JOIN US & LEARN
BR SAVE THIS POST WEB DEVELOPMENT
Q3 Explain unshift() & pop() methods
push/pop/shift/unshift
in Javascript
pets.pop()
pets.shift () & removes
_
pets=['8', ‘a A)
\ inserts
inserts pets.push(' ‘
pets.unshif¢t (' & ‘) &
Well pop and push are easy enough to remember. As for shift and unshift
29 Easy to remember if you mentally drop the "f" in shift / unshift: shift removes
elements and unshift addsthem:)-[——sdJMar2
@developers_community_._ xX @gowsami.devJOIN US & LEARN
BR SAVE THIS POST WEB DEVELOPMENT
Q4 What is difference between 0, NULL & UNDEFINED?
0 - It's just the number zero. let a = null;
null - Null means that something console. log(a);
was defined but is not set. // null
undefined - Undefined most ea
typically means a variable has console. log(b);
been declared, but not defined. // undefined
e
Non-zero value
null undefined
@developers_community._ X @gowsami.devJOIN US & LEARN
BA SAVE THIS POST WEB DEVELOPMENT
Q5 What does the following statement declares?
= ifm it declares a three dimensional array
Q6 Define event bubbling?
/| Window mw
JavaScript allows DOM elements ( ——_—’ |
to be nested inside each other. In CF
such a case, if the handler of the Docuraent
child is clicked, the handler of f
parent will also work as if it were |
clicked too. 1 Event Capturing ‘| Pee 3. Event Bubbling
/
(
\L eae
if
Q7 How cana value be ( )
appended toanarray? “| cae
1 = |
i Ny