DEV Community

Discussion on: Are all JavaScript functions Closures ?

Collapse
 
mayankav profile image
mayankav

@pratiksharm Well, thank you for opening a good discussion. I am afraid its technically not a good idea to call everything in JS an object. Even though we've got object wrappers to make certain methods work flawlessly on primitives, its still better to keep the difference well lit. Such assumptions can lead to mistakes where someone would try assigning a property to some primitive expecting it to be retrievable which in this case will misfire :)

Collapse
 
ganymede profile image
Rudy Reeves

Correct. 5 !== new Number(5). Values and references aren't exactly the same. For most purposes, you can treat everything like an object in JS, but it's nuanced.

Collapse
 
baenencalin profile image
Calin Baenen

I mean, primitives get Object methods, so....

Thread Thread
 
mayankav profile image
mayankav

@baenencalin Hey! I just tried to make this a little more clear in this post

Thread Thread
 
baenencalin profile image
Calin Baenen

I see. And it's a great post.

Thread Thread
 
mayankav profile image
mayankav

:)