Javascript Interview Questions by Frontend Master || #javascript #frontend #reactjs #coding

preview_player
Показать описание
Javascript Interview Questions

Tricky Javascript Interview Question
Hard JS Interview
JS Interview
Javascript
Javascript Interview for experienced
javascript interview question for beginners
best javascript course
master javascript
how to master javascript

Рекомендации по теме
Комментарии
Автор

1. var y = 1; — sets y to 1.
2. The if (function f() {}) condition:
• This declares a function expression named f, but in this context (inside an if statement), it’s not treated as a declaration in the global scope.
• The function itself returns undefined, but the function expression is truthy, so the if block executes.
3. Inside the if block: y += typeof f;
• Here’s the tricky part: f is not defined in this scope because it was not hoisted outside the function expression.
• So typeof f returns "undefined" (not an error).
• y += "undefined" becomes '1undefined' due to type coercion (y becomes a string).
4. console.log(y); outputs:

1undefined

Ayat_iqra_khan
Автор

1undefined because aapki videos se hi seekha hai jo b chez if block k expression mein ati hai woh uske baad destroy ho jati hai.

Aerotk
Автор

❤❤❤❤thanks a lot for constant help to this community. Whenever bad people laid down few good people always stand up for needy ones. Thanks a lot sir for all dev content

siddhartharaja
Автор

this will print 1undefined because the function f() is a expression in the if block and function as expression is a truthy value in js and the typeof f is also undefined so += concatenate the undefined to y and convert the type of y to string

mishiranukao
Автор

Answer is "1undefined", why undefined it's a basic of the if statement in if there is some condition we set (condition) after that it's only returns true or false if condition is satisfied then it under goes to block scope other wise else block scope, so after condition check it's a named function expression so it's was not declared into global scope it declared its self in the if condition scope that's why it was unavailable in scope of if so it's give undefined.

sidhdeshsrivastava
Автор

Its number i think coz if condition will not run as nothing is returned by the function f which is undefined

nishantshah_
Автор

1function

Because the function is hoisted Even if it is written in if block

AnandKumar-
Автор

Y=1 because y function is not call after function

amazingcollection
Автор

"1undefiled" I just tried it.

SandeepRathour-tu
Автор

If function invole there then its return undefined then if block not execute then answer 1

If function declaration behaviour like true then y = 1+ Number = NaN
Answe is NaN

Let me code and see😅

AnkitPatel
visit shbcf.ru