Interview Q&A / TypeScript

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is the difference between object, Object and {} in TypeScript?

SHORT ANSWER

object means any non-primitive (arrays, functions, plain objects). {} means any value that is not null or undefined, including primitives like 5. Object is the wrapper interface with toString and friends and behaves almost like {}. Prefer real shapes or Record instead.

Explain it simply

Think of three gates at a college fest. Gate one (object) lets in only things that are not simple values. Gate two ({}) lets in anything except nothing at all, so even the number 5 gets through. Gate three (Object) is the same crowd with a badge for methods like toString.

Because {} accepts strings and numbers, it is a poor way to say "some object". If you want "an object with any string keys", use Record<string, unknown>. If you know the fields, write them out.

Example

ts
let a: object = { x: 1 };
a = [1, 2];                 // OK: arrays are non-primitive
a = () => 1;                // OK
// a = 5;                   // Error: number is not an object

let b: {} = 5;              // OK: only null and undefined are rejected
b = "hello";                // OK
// b = null;                // Error under strictNullChecks

let c: Record<string, unknown> = { id: 1, name: "Asha" }; // clearer intent

What to say in the interview

"Lowercase object excludes primitives. {} excludes only null and undefined, so a number is assignable to it, which surprises people. Object is the wrapper interface and should be avoided. For a generic bag of properties I use Record<string, unknown>, and for known data I write an interface."

Common mistakes

  • Using {} as a catch-all object type and being surprised that strings pass.

#basic-types#object-types

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.