DEV Community

Cover image for The Differences Between 'Object', '{}', and 'object' in TypeScript

The Differences Between 'Object', '{}', and 'object' in TypeScript

Zach on July 24, 2024

Latest updates in my newsletter. In TypeScript, when we want to define an object type, there are several concise options such as 'Object', '{}', a...
Collapse
 
leob profile image
leob • • Edited

Great post, this is the kind of content that we want to see on dev.to, don't we? :-)

I was totally unaware of "lowercase object" (but I did hear about "Record") - super confusing, as is often the case with Javascript and TypeScript, for historical reasons of how it "came to be" ...

I honestly have no idea why they added "lowercase object", and would never recommend using it in place of "Record", but anyway, nice to know about it.

Collapse
 
igorrubinovich profile image
Igor Rubinovich •

In "This means that all non-primitive types are not assignable to it, and vice versa." you probably meant "assignable" without the "not"

Collapse
 
hansifer profile image
Hans •

They probably meant “all primitive types”, since that’s what’s demonstrated in the code block.

Collapse
 
zacharylee profile image
Zach •

Thanks for your tip, I fixed it.

Collapse
 
earnstein profile image
bakare damilola •

Great content, I'll definitely be referencing this a lot till it's stuck in my brain.

Collapse
 
tonny0831 profile image
tonny_x_bit •

Your teaching is very good. I became know about object.

Collapse
 
octagon profile image
Mostafa •

It's not recommend to use type object, Object and {}
Btw Object it's not typescript specifications, and object a constructive type rarely can be used, maybe if you're writing a library declaration.

Collapse
 
makinator1 profile image
diego fernandez •

Thanks You, easy to understand.

Collapse
 
dshung1997 profile image
Sy Hung Doan •

Informative!

Collapse
 
blackr1234 profile image
blackr1234 •

So the lowercase one is more strict, weird.

Collapse
 
dipakahirav profile image
Dipak Ahirav •

Nice very useful!