JS Number

In JavaScript, numbers are used to represent both integer and floating-point values. JavaScript has only one type of number (unlike other languages which may have int, float, double, etc.).

Types of Numbers in JavaScript

  1. Integers: Whole numbers (e.g., 1, 42, -10)
  2. Floating-Point Numbers: Decimal numbers (e.g., 3.14, -0.99)
  3. Exponential Notation: Large or small numbers using e (e.g., 5e3 is 5000)
  4. NaN (Not-a-Number): Represents an invalid number (e.g., parseInt("hello"))
  5. Infinity & -Infinity: Represents positive or negative infinite values.
Example
let intNum = 42; // Integer
let floatNum = 3.14; // Floating-point number
let expNum = 2e5; // 200000
let infNum = Infinity; // Infinity
let nanValue = NaN; // Not-a-Number

Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.