Javascript interview snippets

Vineet Mishra
Jan 17, 2023

--

Q1. Guess the Output:

var b = 1;
function outer(){
var b = 2
function inner(){
b++;
var b = 3;
console.log(b)
}
inner();
}
outer();
Take a deep breath , don’t jump into solution
Output:
3

Q2. Guess the Output:

var x = 21; var girl = function () { console.log(x); var x = 20; }; girl ();
Take a deep breath , don’t jump into solution
Output:
undefined

--

--

Vineet Mishra
Vineet Mishra

Written by Vineet Mishra

SDE 2 at Accelya , I write about Mobile/Web Development and Deployment, and Interview Q & A

No responses yet