You can convert a BigInt to its corresponding number representation using the
Number() function as follows:
const answerBigInt = 42n; const answerNum = Number(answerBigInt); typeof answerNum; // 'number' answerNum === 42; // true
const tooBig = Number(10n**10000n); tooBig === Number.POSITIVE_INFINITY; // true tooBig; // Infinity const tooSmall = Number((-10n)**10001n); tooSmall === Number.NEGATIVE_INFINITY; // true tooSmall; // -Infinity
- Variables: Variables are used to store data. They are declared using the
- Operators: Operators are used to perform operations on data.
- Control flow statements: Control flow statements allow you to control the order in which your code is executed.
- Functions: Functions are blocks of code that can be reused.
- Objects: Objects are used to store data in key-value pairs.
- Arrays: Arrays are used to store data in a sequential order.
- Events and event handlers: Events are notifications that are sent by the browser when something happens, such as when the user clicks on an element or moves the mouse over an element. Event handlers are functions that are called in response to an event.