add code examples sections

This commit is contained in:
Victor Diez 2023-06-09 12:00:56 +02:00 committed by Victor
parent b468a02725
commit 0420f9defc

View File

@ -40,7 +40,7 @@ myBigInt + 1n === myBigInt + 2n; // false
For large numbers, JavaScript provides the helper function `Number.isSafeInteger()` to test if a number is between the safe limits.
When you need to store a large number, use `BigInt`. `BigInt` and `Number` can be compared between them as usual (e.g. `>`, `==`), but pay attention that arithmetic operations (`+` `pass:[*]` `-` `%` `pass:[**]`) between both types raise an error unless they are converted to the same type,. Use the `BigInt` and `Number` functions to convert between both types:
When you need to store a large number, use `BigInt`. `BigInt` and `Number` can be compared between them as usual (e.g. `>`, `==`), but pay attention that arithmetic operations (`+` `pass:[*]` `-` `%` `pass:[**]`) between both types raise an error unless they are converted to the same type. Use the `BigInt` and `Number` functions to convert between both types:
[source,javascript]
----
const myNumber = Number(myBigInt);