🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number
Number - JavaScript | MDN
A number literal like 37 in JavaScript code is a floating-point value, not an integer. There is no separate integer type in common everyday use. (JavaScript also has a BigInt type, but it's not designed to replace Number for everyday uses.
🌐
W3Schools
w3schools.com › jsref › jsref_number.asp
JavaScript Number() Method
Number() is an ECMAScript1 (JavaScript 1997) feature.
Discussions

Number of bits in Javascript numbers - Stack Overflow
I work in Javascript with integer numbers only (mainly adding numbers and shifting them). I wonder how big they can be without loosing any bits. For example, how big X can be such that 1 More on stackoverflow.com
🌐 stackoverflow.com
javascript - new Number() vs Number() - Stack Overflow
Your shorthands may be simpler, but they are not as clear as using the Number/String/Boolean functions to do the same thing. 2014-01-03T11:20:18.393Z+00:00 ... @Nigel True, but among JavaScript programmers, the + prefix for Number coercion is common and (from what I can see) preferred. More on stackoverflow.com
🌐 stackoverflow.com
math - What is JavaScript's highest integer value that a number can go to without losing precision? - Stack Overflow
Is this defined by the language? Is there a defined maximum? Is it different in different browsers? More on stackoverflow.com
🌐 stackoverflow.com
[JavaScript] nth Prime Number Algorithm
Couple of issues: You return all the numbers less than num, not the numth prime number... the final array is guaranteed to contain fewer elements than are asked for. You should never check even numbers besides 2. Although not technically 'necessary,' you should REALLY have brackets for the for loop on line 4. Line 7 that increments i is problematic... i is already getting incremented as part of the loop, why increment it again? You don't need others Here's my 'fixed' version. It does things a little differently. function PrimeMover(num) { var primes = [2]; for(var i = 3; primes.length < num; i += 2) { var i_isPrime = true; for(var j = 0; j < primes.length && primes[j] * primes[j] <= i; j++) { if(i % primes[j] === 0){ i_isPrime = false; break; /*this will only break the inner loop, and the next i will be checked*/ } } if(i_isPrime){ primes.push(i); } } return primes; } It contains an array of primes that is initialized with 2. It's simply easier that way, at least for me. It only checks odd numbers. It set i_isPrime to be true, then checks by taking the remainder of a subset of lower numbers: it only checks primes because of the fundamental theorem of arithmetic and only checks numbers less than or equal than the square root because if there's a factor larger than the square root, there must also be a factor smaller than the square root. Note that by asserting primes[j] * primes[j] <= i, it asserts that j <= sqrt(i). Generally, a single multiplication is faster than square roots, even though we only need integer precision here. edit This might not be the best approach... it should be better to just calculate the square root of i once and then compare different values of j, since for large primes you might have to test many many possible factors, and big O wrt j is constant time for sqrt as opposed to linear time for multiplying j. However, I'll just say that it's not obvious, and a single multiply should be fast on modern hardware anyway, but if you're optimizing definitely something to consider. If a number isn't proven to be composite by dividing all eligible lower primes, it is then added to the primes Array. Every time the outer loop runs, it makes sure that enough primes haven't been found yet. Once they have been found, the outer loop ends and the Array is returned. The solution I've given is one of the faster 'naive' prime finders, and it's pretty concise. Generally there are better ways to calculate large primes, although for practical purposes, it's probably easiest to just grab a list of large primes off the Internet ;-). More on reddit.com
🌐 r/learnprogramming
4
2
February 14, 2015
🌐
W3Schools
w3schools.com › js › js_numbers.asp
JavaScript Numbers
If you add a string and a number, the result will be a string concatenation: let x = "10"; let y = 20; let z = x + y; Try it Yourself » · A common mistake is to expect this result to be 30: let x = 10; let y = 20; let z = "The result is: " + x + y; Try it Yourself » · A common mistake is to expect this result to be 102030: let x = 10; let y = 20; let z = "30"; let result = x + y + z; Try it Yourself » · The JavaScript interpreter works from left to right.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › Number
Number() constructor - JavaScript | MDN
July 10, 2025 - The Number() constructor creates Number objects. When called as a function, it returns primitive values of type Number.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Numbers
December 18, 2024 - We’re too lazy for that. We’ll try to write something like "1bn" for a billion or "7.3bn" for 7 billion 300 million. The same is true for most large numbers. In JavaScript, we can shorten a number by appending the letter "e" to it and specifying the zeroes count:
🌐
W3Schools
w3schools.com › js › js_number_methods.asp
JavaScript Number Methods
The valueOf() method is used internally in JavaScript to convert Number objects to primitive values.
🌐
Oreate AI
oreateai.com › blog › unpacking-javascripts-parseint-more-than-just-a-number-converter › 0da2767f22c990d25570aad4a622220e
Unpacking JavaScript's parseInt: More Than Just a Number Converter - Oreate AI Blog
2 weeks ago - You've probably encountered it before, perhaps when dealing with user input from a form or trying to make sense of data that's come in as text: parseInt(). It's one of those fundamental JavaScript functions that, on the surface, seems pretty straightforward – you give it a string, and it gives you back an integer. But like many things in programming, there's a bit more nuance under the hood than you might initially expect. At its heart, parseInt() is designed to take a string and attempt to convert its beginning portion into a whole number.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-numbers
JavaScript Numbers - GeeksforGeeks
JavaScript numbers are primitive data types, and unlike other programming languages, you don't need to declare different numeric types like int, float, etc. JavaScript numbers are always stored in double-precision 64-bit binary format IEEE 754.
Published   July 11, 2025
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Numbers_and_strings
Numbers and strings - JavaScript | MDN
In JavaScript, numbers are implemented in double-precision 64-bit binary format IEEE 754 (i.e., a number between ±2^−1022 and ±2^+1023, or about ±10^−308 to ±10^+308, with a numeric precision of 53 bits).
🌐
Medium
medium.com › @aayushgiri1234 › javascript-number-methods-a-comprehensive-guide-28a0c1c68588
JavaScript Number Methods: A Comprehensive Guide | by Aayush Giri | Medium
June 22, 2023 - JavaScript, a dynamic and versatile programming language, provides a variety of methods to work with numbers. These methods allow developers to convert, format, and manipulate numeric data in various ways. This blog post will delve into the details of JavaScript number methods, providing detailed explanations, examples, and code snippets to make the concepts as clear as possible.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_SAFE_INTEGER
Number.MAX_SAFE_INTEGER - JavaScript | MDN
Number.MAX_SAFE_INTEGER represents ... The largest representable number in JavaScript is actually Number.MAX_VALUE, which is approximately 1.7976931348623157 × 10308....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_VALUE
Number.MAX_VALUE - JavaScript | MDN
October 22, 2025 - The Number.MAX_VALUE static data property represents the maximum numeric value representable in JavaScript.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › parseInt
Number.parseInt() - JavaScript | MDN
function roughScale(x, base) { const parsed = Number.parseInt(x, base); if (Number.isNaN(parsed)) { return 0; } return parsed * 100; } console.log(roughScale(" 0xF", 16)); // Expected output: 1500 console.log(roughScale("321", 2)); // Expected output: 0
🌐
DEV Community
dev.to › imsushant12 › a-guide-to-master-numbers-data-type-in-javascript-37m4
A Guide to Master Numbers Data Type in JavaScript - DEV Community
July 20, 2024 - In this article, we'll explore the various number functions in JavaScript, providing detailed explanations, examples, and comments to help you master them.
Top answer
1 of 5
76

Boolean(expression) will simply convert the expression into a boolean primitive value, while new Boolean(expression) will create a wrapper object around the converted boolean value.

The difference can be seen with this:

Copy// Note I'm using strict-equals
new Boolean("true") === true; // false
Boolean("true") === true; // true

And also with this (thanks @hobbs):

Copytypeof new Boolean("true"); // "object"
typeof Boolean("true"); // "boolean"

Note: While the wrapper object will get converted to the primitive automatically when necessary (and vice versa), there is only one case I can think of where you would want to use new Boolean, or any of the other wrappers for primitives - if you want to attach properties to a single value. E.g:

Copyvar b = new Boolean(true);
b.relatedMessage = "this should be true initially";
alert(b.relatedMessage); // will work

var b = true;
b.relatedMessage = "this should be true initially";
alert(b.relatedMessage); // undefined
2 of 5
40
Copynew Number( x )

creates a new wrapper object. I don't think that there is a valid reason to ever use this.

CopyNumber( x )

converts the passed argument into a Number value. You can use this to cast some variable to the Number type. However this gets the same job done:

Copy+x

Generally:

You don't need those:

Copynew Number()
new String()
new Boolean()

You can use those for casting:

CopyNumber( value )
String( value )
Boolean( value )

However, there are simpler solutions for casting:

Copy+x // cast to Number
'' + x // cast to String
!!x // cast to Boolean
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Data_structures
JavaScript data types and data structures - JavaScript | MDN
Variables in JavaScript are not directly associated with any particular value type, and any variable can be assigned (and re-assigned) values of all types: ... let foo = 42; // foo is now a number foo = "bar"; // foo is now a string foo = true; // foo is now a boolean
🌐
Medium
medium.com › @techwithtwin › javascript-numbers-explained-techwithtwin-704a9fbe4f4f
JavaScript Numbers Explained | TechWithTwin | by TechWithTwin | Medium
June 11, 2025 - A number is a JavaScript data type representing digits and floating-point numbers, i.e, decimals.
Top answer
1 of 16
1011

JavaScript has two number types: Number and BigInt.

The most frequently-used number type, Number, is a 64-bit floating point IEEE 754 number.

The largest exact integral value of this type is Number.MAX_SAFE_INTEGER, which is:

  • 253-1, or
  • +/- 9,007,199,254,740,991, or
  • nine quadrillion seven trillion one hundred ninety-nine billion two hundred fifty-four million seven hundred forty thousand nine hundred ninety-one

To put this in perspective: one quadrillion bytes is a petabyte (or one thousand terabytes).

"Safe" in this context refers to the ability to represent integers exactly and to correctly compare them.

From the spec:

Note that all the positive and negative integers whose magnitude is no greater than 253 are representable in the Number type (indeed, the integer 0 has two representations, +0 and -0).

To safely use integers larger than this, you need to use BigInt, which has no upper bound.

Note that the bitwise operators and shift operators operate on 32-bit integers, so in that case, the max safe integer is 231-1, or 2,147,483,647.

const log = console.log
var x = 9007199254740992
var y = -x
log(x == x + 1) // true !
log(y == y - 1) // also true !

// Arithmetic operators work, but bitwise/shifts only operate on int32:
log(x / 2)      // 4503599627370496
log(x >> 1)     // 0
log(x | 1)      // 1


Technical note on the subject of the number 9,007,199,254,740,992: There is an exact IEEE-754 representation of this value, and you can assign and read this value from a variable, so for very carefully chosen applications in the domain of integers less than or equal to this value, you could treat this as a maximum value.

In the general case, you must treat this IEEE-754 value as inexact, because it is ambiguous whether it is encoding the logical value 9,007,199,254,740,992 or 9,007,199,254,740,993.

2 of 16
509

>= ES6:

Number.MIN_SAFE_INTEGER;
Number.MAX_SAFE_INTEGER;

<= ES5

From the reference:

Number.MAX_VALUE;
Number.MIN_VALUE;

console.log('MIN_VALUE', Number.MIN_VALUE);
console.log('MAX_VALUE', Number.MAX_VALUE);

console.log('MIN_SAFE_INTEGER', Number.MIN_SAFE_INTEGER); //ES6
console.log('MAX_SAFE_INTEGER', Number.MAX_SAFE_INTEGER); //ES6