1. What is the result of the following code: 'let a = 5; function example() { let a = 10; console.log(a); } example(); console.log(a);' 10, 5 5, 10 10, undefined undefined, 5 Wrong 2. What is the scope of a variable in JavaScript? The geographical area where a variable is declared The range of values a variable can hold The context in which a variable is accessible The data type of a variable Wrong 3. What is a closure in JavaScript? A function that has no access to its own scope A function that can access variables from its own scope and the scope in which it was created A variable declared inside a loop A variable with a constant value Wrong 4. Consider the following code: 'function outer() { let x = 10; function inner() { console.log(x); } return inner; } let closureFunc = outer(); closureFunc();'. What will be logged to the console? 10 undefined ReferenceError outer Wrong 5. How can you avoid variable name conflicts in JavaScript? By using short and unique variable names By using the same variable names in different scopes By avoiding the use of functions By properly using local and global scopes Wrong 6. What is the difference between global scope and local scope in JavaScript? Global scope is for variables declared inside a function, local scope is for variables declared outside any function Global scope is for variables declared outside any function, local scope is for variables declared inside a function There is no difference between global and local scope Global scope is for numbers, local scope is for strings Wrong 7. What is the 'lexical scope' in JavaScript? The scope of a variable defined inside a loop The scope of a variable declared using 'let' or 'const' The scope determined by the position of the function's definition in the source code The scope of a variable passed as an argument to a function Wrong 8. How does a closure help with encapsulation in JavaScript? By hiding the implementation details of a function By making all variables global By exposing all variables to the outer scope By preventing the use of functions Wrong 9. How can you create a private variable in JavaScript using closures? By declaring the variable with 'var' By using the 'static' keyword By declaring the variable inside a function and returning a function that accesses it There is no way to create private variables in JavaScript Wrong 10. What happens if you try to access a variable outside its scope in JavaScript? The variable becomes global automatically A new local variable with the same name is created An error occurs, and the program stops executing The variable loses its value Wrong Result: Share on Facebook