
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
BigInt in JavaScript
The BigInt is an inbuilt object that is used for representing whole numbers larger than 253 - 1.
Following is the code to implement BigInt in JavaScript −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; color: blueviolet; } </style> </head> <body> <h1>BigInt in JavaScript</h1> <div class="result"></div> <br /> <button class="Btn">CLICK HERE</button> <h3>Click on the above button to display a BigInt number</h3> <script> let resEle = document.querySelector(".result"); let BtnEle = document.querySelector(".Btn"); BtnEle.addEventListener("click", () => { resEle.innerHTML = BigInt(9007199254740991) + "<br>"; resEle.innerHTML += BigInt(Number.MAX_SAFE_INTEGER) + "<br>"; }); </script> </body> </html>
Output
On clicking on ‘CLICK HERE’ button −
- Related Articles
- Using BigInt to calculate long factorials in JavaScript
- Difference between BIGINT and BIGINT(20) in MySQL?
- MySQL BigInt zerofill vs int zerofill?
- How to use BIGINT(8)value in Android sqlite?
- Difference between MySQL BigInt(20) and Int(20)?
- How do I cast a type to a BigInt in MySQL?
- Is BIGINT(8) the largest integer MySQL can store?
- How to understand if a bigint is signed or unsigned in MySQL?
- Get the count of unique phone numbers from a column with phone numbers declared as BIGINT type in MySQL
- Deviations in two JavaScript arrays in JavaScript
- Keeping only alphanumerals in a JavaScript string in JavaScript
- Number.NEGATIVE_INFINITY in JavaScript
- Number.POSITIVE_INFINITY in JavaScript
- Node in Javascript
- Mixins in JavaScript

Advertisements