In JavaScript, number is a primitive - data that is not an object and has no methods or properties.

However, Number is an object which wraps a primitive (number). It is used to represent and manipulate numbers. Its constructor contains constants and methods for working with numbers.

Data type refers both to primitive values and objects. This is why Number is also a data type. Number is a global object because it is an object that always exists in the global scope.

Answer from Omer Sherer on Stack Overflow
🌐
W3Schools
w3schools.com › js › js_numbers.asp
JavaScript Numbers
let x = 3.14; // A number with decimals let y = 3; // A number without decimals ... Unlike many other programming languages, JavaScript does not define different types of numbers, like integers, short, long, floating-point etc.
🌐
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.
Discussions

Number as a JavaScript data type and a global object - Stack Overflow
From this documentation page I read that Number refers to both a data type and a global object. Surely it is not a coincidence that the data type and the global object are both written as Number, r... More on stackoverflow.com
🌐 stackoverflow.com
javascript - What is the difference between "number" and "Number" in TypeScript? - Stack Overflow
On the other hand, user-defined types like classes appear to be discrete values (as they also print the standard function description). Yes. Classes, of which Number is one, are special. They do two things, somewhat unintuitively: They create a JavaScript class (usable in emitted code) More on stackoverflow.com
🌐 stackoverflow.com
Why do I got "Type 'string | number' is not assignable to type 'never'. Type 'string' is not assignable to type 'never'. " it's make me misleading
TL;DR : It's because of the string|number. Ok how do we find the root cause of the issue, the first intuition could be the Enum things, let's simplify the exemple and get rid of the enum : function test(key: 'A' | 'B', value: number | string) { let data = {A: 1, B: "1"}; data[key] = value; // Type 'string' is not assignable to type 'never'. } No luck, it's not about the Enum keys :( What about the number | string, let's play with numbers only: function test(key: 'A' | 'B', value: number) { let data = {A: 1, B: 2}; data[key] = value; // it works. } It works ! So what is the problem ? If your IDE is smart enough, when you put your mouse on the data variable it should show its type, and it should be this : {A: number, B: string} ... But wait, I suppose it's not what you want, actually what you want ( I guess but not sure) is {A: string|number, B: string|number}. If it's the case you have to specify the data type because typescript is going too far in its type inference. let data: Record = {A: 1, B: '2'}; So, finally why does it fails ? Since TS assume that A is a number and B is a string and your value is string | number. So data['A'] = value fails because value needs to be number but is actually number|string. And the same things happens for the data['B'], meaning this assignement is never correct ... More on reddit.com
🌐 r/typescript
8
4
June 16, 2020
Old meme format, timeless JavaScript quirks
Honestly, just using === everywhere will save you a lot of trouble. More on reddit.com
🌐 r/ProgrammerHumor
434
26567
March 20, 2018
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › javascript fundamentals
Data types
Programming languages that allow ... but variables are not bound to any of them. ... The number type represents both integer and floating point numbers....
🌐
Medium
medium.com › @RomarioDiaz25 › javascript-tutorial-numbers-c5155388bd95
JavaScript Tutorial: Numbers. JavaScript’s primary numeric type… | by Romario Diaz | Medium
September 29, 2023 - JavaScript Tutorial: Numbers JavaScript’s primary numeric type, Number, is used to represent integers and to approximate real numbers. JavaScript represents numbers using the 64-bit floating-point …
🌐
Wes Bos
wesbos.com › javascript › 01-the-basics › types-numbers
Types - Numbers - Wes Bos
Open types.html in the browser and then open the console and type typeof age and hit enter. The console should return to you "number". typeof is a keyword in JavaScript that allows you to check the type of a value.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Number
Number - Glossary | MDN
July 11, 2025 - In JavaScript, Number is a numeric data type in the double-precision 64-bit floating point format (IEEE 754). In other programming languages different numeric types exist; for example, Integers, Floats, Doubles, or Bignums.
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
Top answer
1 of 2
2

In JavaScript, number is a primitive - data that is not an object and has no methods or properties.

However, Number is an object which wraps a primitive (number). It is used to represent and manipulate numbers. Its constructor contains constants and methods for working with numbers.

Data type refers both to primitive values and objects. This is why Number is also a data type. Number is a global object because it is an object that always exists in the global scope.

2 of 2
1

Number refers to a global constructor function that, when called, returns a number (or, in very strange cases, a Number object).

number is the string returned by the typeof operation - or, the word one uses to describe a number primitive.

It's only a capitalization difference, but it's quite an important distinction.

const str = '34';
const num = Number(str);
console.log(typeof num);

What exactly is this Number object? Is it an instance of some class?

Number itself is a class, kind of - a function that can be called, possibly with new, which will return a value that inherits from Number.prototype. (Although it's not syntactically forbidden, best to never use new with Number)

Unlike some languages, JavaScript types aren't really values you can work with and manipulate inside a script. You can say, when looking at a piece of code: "This variable points to a number" - and you can use the typeof operator to extract the string representation of the type from a value - but that's it. In actual JavaScript code, there isn't a number value or type that can be referenced in the code to do something with (other than when as part of a string in conjunction with the use of typeof). This is in contrast with, for example, TypeScript, where you could do type NumObj = { theValue: number } and declare const theMap: Map<number, string>, and lots of other interesting things - but JavaScript only has the 'number' that typeof returns, and the Number constructor and its methods.

Number is a constructor function, but it also has static methods - methods directly on the constructor, not on the prototype object, such as isInteger - a utility function related to numbers that isn't that particular to a given number instance.

🌐
Angular.love
angular.love › here-is-what-you-need-to-know-about-javascripts-number-type
JavaScript’s Number type - what you need to know it
October 12, 2017 - According to the ECMAScript standard, there is only one type for numbers and it is the ‘double-precision 64-bit binary format IEEE 754 value’. This type is used to store both integers and fractions and is the equivalent of `double` data ...
Top answer
1 of 2
38

number is only a TypeScript thing - it's a primitive type referring to, well, a number.

But, judging by the error message, it seems that number isn't actually a discrete value like Number.

Indeed - it's a type, so it doesn't exist in emitted code.

a discrete value like Number. On the other hand, user-defined types like classes appear to be discrete values (as they also print the standard function description).

Yes. Classes, of which Number is one, are special. They do two things, somewhat unintuitively:

  • They create a JavaScript class (usable in emitted code)
  • They also create an interface for the class (only used by TypeScript)

If you use Number in a place where a type is expected, TypeScript will not complain, because Number is an interface.

If you use Number in a place where a value (something that exists in emitted code) is expected, TypeScript will not complain, because Number is also a global constructor.

In other words, the two Numbers below refer to completely different things:

// refer to the TypeScript Number interface
let foo: Number;

// refer to the JavaScript global.Number constructor
const someNum = Number(someString);

Using Number in TypeScript is very odd, since it'd, strictly, speaking, refer to a number created via new:

const theNum = new Number(6);

Which there's almost never a reason to do. Use a plain primitive number instead, without an object wrapper.

const theNum = 6;
// theNum is typed as `number`
2 of 2
1

From https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean:

JavaScript has three very commonly used primitives: string, number, and boolean. Each has a corresponding type in TypeScript. As you might expect, these are the same names you’d see if you used the JavaScript typeof operator on a value of those types:

  • string represents string values like "Hello, world"
  • number is for numbers like 42. JavaScript does not have a special runtime value for integers, so there’s no equivalent to int or float - everything is simply number
  • boolean is for the two values true and false

The type names String, Number, and Boolean (starting with capital letters) are legal, but refer to some special built-in types that will very rarely appear in your code. Always use string, number, or boolean for types.

(There are also typs for null and undefined)

🌐
Mimo
mimo.org › glossary › javascript › numbers
Mastering JavaScript Numbers: Manipulate Numeric Data
JavaScript treats whole numbers (like 42) and decimal numbers (like 3.14) the same way—both are instances of the Number type.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-number-reference
JavaScript Number Reference - GeeksforGeeks
1 month ago - In JavaScript, a constructor gets called when an object is created using the new keyword. Number(): Number() constructor returns the number format for any type of JavaScript variable.
🌐
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). Integer values up to ±2^53 − 1 can be represented exactly.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Data_structures
JavaScript data types and data structures - JavaScript | MDN
July 8, 2025 - All primitive types, except null and undefined, have their corresponding object wrapper types, which provide useful methods for working with the primitive values. For example, the Number object provides methods like toExponential(). When a property is accessed on a primitive value, JavaScript automatically wraps the value into the corresponding wrapper object and accesses the property on the object instead.
🌐
TypeScript Tutorial
typescripttutorial.net › home › typescript tutorial › typescript number
TypeScript Number
October 18, 2024 - All numbers in TypeScript are either floating-point values or big integers. The floating-point numbers have the type number while the big integers get the type bigint. The following shows how to declare a variable that holds a floating-point value: let price: number;Code language: JavaScript ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › input › number
<input type="number"> - HTML | MDN
A number representing the value of the number entered into the input. You can set a default value for the input by including a number inside the value attribute, like so: ... In addition to the attributes commonly supported by all <input> types, inputs of type number support these attributes.
🌐
DEV Community
dev.to › igadii › beyond-basics-handling-numeric-inputs-like-a-pro-with--40bf
Beyond Basics: Handling Numeric Inputs Like a Pro with `<input type="number">`
December 4, 2025 - According to MDN Docs Definition: <input> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries. So basically, it is a feature for enhancing User Experience on our crappy ...
🌐
Medium
medium.com › javascript-in-plain-english › how-to-check-for-a-number-in-javascript-8d9024708153
How to check for a number in JavaScript | by Dr. Derek Austin 🥳 | JavaScript in Plain English | Medium
November 19, 2020 - It is actually unnecessary to write custom functions to check for a number, though it is an instructive way to remember that the JavaScript values Infinity, -Infinity, and NaN are all of the number primitive type.
🌐
typescriptlang.org
typescriptlang.org › docs › handbook › 2 › everyday-types.html
TypeScript: Documentation - Everyday Types
We’ll start by reviewing the most basic and common types you might encounter when writing JavaScript or TypeScript code. These will later form the core building blocks of more complex types. JavaScript has three very commonly used primitives: string, number, and boolean.
🌐
W3Schools
w3schools.com › js › js_datatypes.asp
JavaScript Data Types
This means that the same variable can be used to hold different data types: let x; // Now x is undefined x = 5; // Now x is a Number x = "John"; // Now x is a String Try it Yourself » · A JavaScript object can represent a JavScript object or a User defined object.