Test your expertise on advanced JavaScript concepts and foundational knowledge of modern frameworks including React, Vue, and Angular. Expect scenario-based and concept-driven questions for deep understanding.
Closures and Scope Control
In JavaScript, what is the output of the following code snippet: let funcs = []; for (var i = 0; i u003C 3; i++) { funcs[i] = function() { return i; }; } console.log(funcs[0]());
- 0
- ReferenceError
- null
- 3
- undefined
React State Management
In React, which statement best describes the consequence of directly mutating a component's state without using setState?
- It throws a runtime error immediately.
- ComponentWillMount is automatically called.
- The UI will not reflect the updated state value.
- It improves performance by skipping re-render.
- It triggers the error boundary to run.
Vue Reactivity System
Considering Vue 3’s composition API, which method is primarily used to make a plain object reactive so that changes to its properties trigger updates?
- updateReactive
- effect
- reactive
- refactor
- respond
Arrow Functions and this
Which of the following is true about the behavior of 'this' inside an arrow function in JavaScript?
- Arrow functions use the enclosing lexical context's 'this'.
- 'this' cannot be used inside arrow functions.
- 'this' in arrow functions is dynamically scoped.
- Arrow functions have their own 'this' based on call-site.
- 'this' always refers to the global object in arrow functions.
Angular Dependency Injection
Which of the following is a key advantage of using dependency injection in Angular’s architecture?
- Improved testability and modularity
- Global variable isolation
- Reduced code readability
- SVG rendering enhancement
- Mandatory global state management
Async Patterns and Promises
What will be logged by the following code: Promise.resolve(42).then(x =u003E { throw x }).catch(y =u003E y + 1).then(z =u003E console.log(z));
- 43
- 42
- Promise
- TypeError
- undefined
React Key Prop Importance
Why is it critical to provide a 'key' prop when rendering a list of React elements using the map function?
- To increase render speed by skipping the virtual DOM
- To help React identify which items have changed, added, or removed
- Because omitting it throws a syntax error
- To enable the useEffect hook in child components
- To prevent styles from reloading on every render
Vue Template Binding Syntax
In Vue, which template syntax is used to bind an element’s attribute dynamically to a JavaScript expression?
- bind-val
- :bind
- @bind
- v-attribute
- v-bind
JavaScript Event Loop
If both a 'setTimeout' with a 0ms delay and a 'Promise.then' are called in a JavaScript execution context, which will execute first and why?
- It is unpredictable due to the single-thread event loop
- setTimeout executes first because it is asynchronous
- setTimeout always executes before Promises by specification
- Promise.then executes first because microtasks have higher priority than macrotasks
- They execute simultaneously because delay is zero
Angular Change Detection
What mechanism does Angular predominantly use to check and update the DOM when application state changes?
- MutationObserver
- WebSockets polling
- VirtualDOM diff
- RequestAnimationFrame
- Zone-based change detection
Object Destructuring with Default Values
Given const {x = 3, y} = {y: 10}; what are the values of x and y after destructuring?
- x is undefined, y is 3
- x is 3, y is 10
- x is 10, y is undefined
- x is 10, y is 3
- x is 3, y is undefined
React useEffect Dependencies
What is the result if you call React's useEffect hook without providing a second argument (dependencies array)?
- The effect causes a render loop.
- The effect runs only once after the initial render.
- It throws a syntax error.
- The effect never runs.
- The effect runs after every completed render.
Vue Computed Properties vs Methods
Which is a distinguishing characteristic of Vue’s computed properties compared to methods for accessing derived data?
- Methods provide automatic dependency tracking.
- Methods can only be used for event handling.
- Computed properties are always asynchronous.
- Computed properties cannot access component data.
- Computed properties are cached based on their dependencies.
TypeScript's Type System in Frameworks
What TypeScript feature most commonly enhances code reliability in large modern JavaScript frameworks?
- Synchronous event loops
- Static type checking
- Dynamic prototype chaining
- Global variable hoisting
- Implicit coercion overrides
Angular Decorators
Which decorator in Angular is used to mark a class as a component and supply its metadata such as templates and styles?
- @View
- @Module
- @Component
- @Service
- @Directive
JavaScript Symbol Uniqueness
Which statement correctly describes two JavaScript symbols created with Symbol('id') and Symbol('id')?
- They are the same if created within the same closure.
- They are numbers under the hood.
- They are equal if the same string was passed.
- They are coerced to boolean true when compared.
- They are always unique and do not equal each other.