JavaScript Interview Questions: Scope, Hoisting, Closures, Asynchronous

📌 GUESS THE OUTPUT These JavaScript output-based interview questions are designed to evaluate your understanding of core concepts, including scope, hoisting, closures, and asynchronous behavior. #JavaScript #InterviewPreparation #SoftwareEngineering #FrontendDevelopment #DevelopersOfLinkedIn

  • text

When test(5) is called, the value 5 is passed to the parameter a, so a initially becomes 5. Inside the function, the var a declaration is hoisted to the top, but since a already exists as a function parameter, this hoisted declaration does not change its value. Then console.log(a) runs and prints the current value of a, which is 5.

function test(a) {     // var a;   // hoisted, but parameter already defines `a`     console.log(a); // prints the parameter value → 5     a = 10; // assignment happens after the log }

See more comments

To view or add a comment, sign in

Explore content categories