Explain JS types, Promises, Maps, WebSockets
Company: Citadel
Role: Software Engineer
Category: Other / Miscellaneous
Difficulty: medium
Interview Round: Technical Screen
Discuss JavaScript data types and common data structures. Which values coerce to false in a boolean context? For Promises, what do then/catch/finally handlers return, and what happens to the returned Promise if an error is thrown in the executor or in any handler (including within an async function)? Compare plain objects and Map in terms of key types, iteration order, default properties, performance, and typical use cases. What is a WeakMap, and how do its key constraints and garbage-collection behavior differ from Map? For WebSockets, explain whether a single connection guarantees in-order, reliable delivery of messages, when ordering might be affected (e.g., multiple connections, reconnections, server fan-out), and how you would design for ordering/idempotency if required.
Quick Answer: This question evaluates understanding of JavaScript language fundamentals (primitive vs reference types and boolean coercion), asynchronous programming and error propagation with Promises, differences among collection types (Object, Map, WeakMap) including key constraints and GC behavior, and WebSocket message ordering and reliability.