Tuples vs. Objects

What

Tuples and objects are both used to group related data, but they serve different semantic purposes.

How

Use a tuple when the data has a conventional or mathematical order. Use an object when the data is descriptive and requires named access:

// Tuple: Order is conventional (Lat, Lng)
const coords: [number, number] = [40.7128, -74.006];

// Object: Order doesn't matter, descriptive keys are better
const user = { name: "Lane", age: 30 };

Why

Tuples are concise and fit well for positional data (like a pair of coordinates or a [key, value] pair). However, for complex data structures like a “User” profile, using a tuple (e.g., [string, number, string]) becomes confusing because the index doesn’t describe the data it holds.

Summary

If you find yourself wondering “what was at index 2 again?”, you should probably be using an object instead of a tuple.