JavaScript Types, Promises, Collections, and WebSocket Ordering
You are interviewing for a software engineering role. Answer the following about JavaScript runtime behavior, collections, and networking:
1) Data Types and Data Structures
-
List JavaScript primitive types vs reference types.
-
Name common built-in data structures used in practice.
-
Which values coerce to false in a boolean context?
2) Promises: Return Values and Error Propagation
-
What do
then
/
catch
/
finally
return?
-
What happens if an error is thrown in the Promise executor or in any handler (including inside an
async
function)?
3) Plain Objects vs Map
Compare by:
-
Key types allowed
-
Iteration order
-
Default/inherited properties and collision issues
-
Performance characteristics (adds/removes/lookups)
-
Typical use cases
4) WeakMap
-
What is it?
-
How do its key constraints and garbage-collection behavior differ from
Map
?
5) WebSockets and Message Ordering
-
Does a single WebSocket connection guarantee in-order, reliable delivery?
-
When can ordering be affected (e.g., multiple connections, reconnections, server fan-out)?
-
How would you design for ordering and/or idempotency if required?