
- 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
How to print positive and negative infinity values in JavaScript?
Following is the code for printing positive and negative infinity values 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; } .num { font-size: 18px; font-weight: 500; } </style> </head> <body> <h1>JavaScript Infinity property</h1> <div class="num">1.797693134862315E+10308</div> <div class="num">-1.797693134862315E+10308</div> <button class="Btn">CLICK HERE</button> <h3> Click on the above button to add and subtract the above floating numbers by 1 respectively </h3> <script> let sampleEle = document.querySelector(".sample"); let num1 = document.querySelectorAll(".num")[0]; let num2 = document.querySelectorAll(".num")[1]; document.querySelector(".Btn").addEventListener("click", () => { num1.innerHTML = +num1.innerHTML + 1; num2.innerHTML = +num2.innerHTML - 1; }); </script> </body> </html>
Output
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
- Related Articles
- Test array values for positive or negative infinity in Numpy
- What is negative infinity in javascript?
- Test element-wise for positive or negative infinity in Numpy
- How to create bar plot with positive and negative values in R?
- How to convert negative values in an R data frame to positive values?
- Replace NaN with zero and fill negative infinity values in Python
- Reversing negative and positive numbers in JavaScript
- Replace NaN with zero and fill positive infinity values in Python
- Print all the pairs that contains the positive and negative values of an element in C++
- Sum a negative number (negative and positive digits) - JavaScript
- Python - Sum negative and positive values using GroupBy in Pandas
- Java Program to convert positive int to negative and negative to positive
- Converting boolean values to positive or negative sign in MySQL?
- How to convert a negative number to a positive one in JavaScript?
- How to GROUP BY in a select query on positive or negative values?

Advertisements