Trick JavaScript Interview questions
Published in
1 min readApr 23, 2011
We were asked some tricky JavaScript questions that Alex(the lead) used in interviews for the internship position. Here are some of them:
Question 1:
//What is i?
var i=0;
var add = function(){
++i;
return function(){
i++;
return function(){
i++;
add();
}
}
};
add()()();
Question 2:
//What is the value and data type of result?
var result = !!String("false");
Question 3:
//What is result?
var result = "1"+2+4;
Question 4:
//What is 'result' and why?
var result = (function foo(bar){
return !bar;
}(false)? false: true);
Answers:
1) 4
2) true, boolean
3) 124
4) false