Node.js Data
Node code often moves between JavaScript objects, arrays, JSON payloads, and binary buffers. Knowing the difference keeps APIs predictable.
Objects and arrays
const user = { name: "Ada", active: true };
const tags = ["api", "node", "lab"];
JSON
JSON is the wire format for many Node APIs. Convert values intentionally and validate data before trusting it.
Buffers
Buffers represent binary data. They matter when you work with files, streams, encoding, or network packets.
Practice
- Create one object and one array.
- Serialize the object to JSON and back again.
- Write one sentence about when to use a buffer instead of a string.