Interview Q&A / TypeScript

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is the difference between number and Number in TypeScript?

SHORT ANSWER

number is the primitive type you should use. Number (capital N) is the type of the wrapper object created by new Number() and is almost never what you want; the same applies to string vs String and boolean vs Boolean.

Explain it simply

JavaScript has two ways to hold a number: the plain value 5, and a box that wraps it, new Number(5). The box is like keeping a 500 rupee note inside a gift envelope: the note is the same, but now it is a different kind of thing.

TypeScript mirrors this. Lowercase number means the primitive. Uppercase Number describes the wrapper object, and because a primitive is assignable to it, the types blur and mistakes slip in. Linters flag the uppercase forms for this reason.

Example

ts
let a: number = 5;
let b: Number = 5;          // allowed, but misleading

// a = b;                   // Error: 'Number' is not assignable to 'number'
b = a;                      // fine: primitive goes into the wrapper type

const boxed = new Number(5);
console.log(typeof boxed);  // "object"
console.log(typeof 5);      // "number"

function double(n: number) { return n * 2; } // always write lowercase

What to say in the interview

"Lowercase number, string and boolean are the primitive types and the ones to use. Uppercase Number, String and Boolean are wrapper object types. They exist because JavaScript has wrappers, but using them as annotations is a bug magnet, and the typescript-eslint ban-types rule warns against them."

Common mistakes

  • Annotating with String or Number because it 'looks more like a class'.

#basic-types#primitives

Related questions

Practise more TypeScript questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open TypeScript quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.