blog

TIL: Tuple

I googled the term today after a colleague mentioned it in a code comment.

https://isaaccomputerscience.org/concepts/dsa_datastruct_tuple?examBoard=all&stage=all

A tuple is an ordered sequence of elements that is immutable, which means that the values within the tuple cannot be modified when the program is running. The elements of a tuple can be of different data types, e.g. a mix of strings and integers.

Turns out, JavaScript doesn’t have tuples but they can be faked using array destructuring. Also, use Object.freeze for immutability.