OpenAI · CS Fundamentals
Explain JS threading and useState vs useRef
TrueInterview
October 7, 2026 · 1 min read
Respond to the following conceptual prompts about JavaScript and React:
- JavaScript and multithreading
- How does JavaScript's execution model operate in the browser or in Node.js?
- Is JavaScript itself multithreaded? If it is not, how does it handle concurrency?
- What options, if any, are available for using multiple threads (for example, Web Workers or worker threads), and what restrictions do they carry?
- React
useStatevsuseRef- What role does the
useStatehook serve, and how does it affect component re-renders? - What role does the
useRefhook serve? How does its behavior differ fromuseState? - When would you pick
useStateoveruseRef, or the reverse? Provide a few specific examples. Give enough detail that a junior engineer can grasp the main differences and trade-offs.
- What role does the
Overview: This prompt tests knowledge of JavaScript's execution model and concurrency tools (including worker-based threading), as well as React state-management semantics, especially the behavioral contrast between useState and useRef.
Loading comments…