Related Posts
Is “Hacking the Case Interview” any good?
Tata Consultancy Yesterday I got call from the tcs, they told that i have cleared the interview and they will send me mail for documents upload but till now i didn't got any mail... I am trying to call back but no one is picking, can anyone suggest me how much time they'll took for sending the mail for documentation
More Posts
Any REIT ETFs that people like?
Additional Posts in Consulting India
I received TCS offer 10 days after I joined another company as they took more than month to release my offer. My BGV came negative saying you are working for another employer. I tried convincing HR that I am ready to resign now again and join TCS within a month as my initial joining date with TCS is also in December but she says offer is cancelled as you didn't inform me of your joining to another company. How valid is this? Tata Consultancy
New to Fishbowl?
unlock all discussions on Fishbowl.





as per as I understand output will be -
undefined
5
function body(not sure abt this)
function body
Totally based on hoisting. Have a look at "var" keyword and hoisting. Hope this helps.
Correct
Hi Buddy-
The output would be like this -
Function definition of a
5
Function definition of a
Function definition of a
Based upon the hoisting concept, it picked up the declaration from the bottom of the code where it defines a as a function.
Then, its definition changed to plain number 5, so it gets printed.
Next, it is just the same thing but used ES6 syntax to define a as a function. Hence, same function definition is printed.
Lastly, again it is defining a as a function and gets printed. :)
No, because it goes to the bottom and able to see the declaration of A defined as a function.
Were they separate? Looks like a question related to hoisting to me.
btw, excellent question I must say. Can you share me some more interview qn.s on JS. I am also giving interviews
Pro
Omg
I just want to add one more thing.. I think here the key is that function hoisting takes precedence over variable hoisting.
Almost close. Basically hoisting consider only declarations not initializations. So let's suppose, if we define console.log(a); a = 5; var a=6; then it would print a's values at each step as null, 5,6