Which statement is true regarding function scope in JavaScript?
- Functions can access variables from outer scopes.
- Variables declared inside functions have global scope.
- Variables declared inside functions have function scope.
- Variables declared inside functions are accessible only within that function's block.
In JavaScript, variables declared inside functions have function scope, meaning they are only accessible within that function. This is important for encapsulation and avoiding variable conflicts. Variables declared outside of functions have global scope, and functions can access variables from outer scopes, but the reverse is not true.
Loading...
Related Quiz
- To iterate over the keys in an object, you can use the for...______ loop.
- In JavaScript, the Symbol data type can be used to create _________.
- How does event looping handle while(true) in Node.js environments?
- How does the await keyword manage the Promise’s resolve value?
- What is a potential downside of using async/await syntax?