Magic numbers make the code more complex to understand as it requires the reader to have knowledge about the global context to understand the
number itself. Their usage may seem obvious when writing the code, but it may not be the case for another developer or later once the context faded
away. -1, 0, and 1 are not considered magic numbers.
Exceptions
- the following numbers used in arithmetic operations: -1, 0, 1, as well as powers of 2 and 10
- time-related constants such as 24 and 60 are excluded
- numbers used in JSX elements are excluded
- enum values, default values, and other assignments are excluded
- arguments to
parseInt()
and JSON.stringify()
are excluded
- numbers used in bitwise operations are excluded