r/ProgrammerHumor • • Mar 20 '24

Meme areJSDevsActuallySane

Post image
14k Upvotes

554 comments sorted by

View all comments

Show parent comment

1

u/MajorTechnology8827 Mar 20 '24

Because {} is an object

Plain and simple, that's what an object is in JavaScript. A collection of properties encased in curly braces. Like how you define dictionary in any other language? An object in Javascript is a dictionary

{} Is a dictionary with exactly 0 keys. Its an object with no properties. You sent an empty object into regex, regex wanted a string, it converted your object into a string. The default behavior of string is well documented

The code is consistent and sensical. If a programmer doesn't care to understand the fundamentals of JavaScript object system (which is inherently different than other languages as JavaScript is not a Java/C-clone) Than he shouldn't jump to a conclusion on how he thinks it should work

1

u/No-Con-2790 Mar 20 '24

Again, I know the how. It was clearly explained. But I don't understand why anybody was implementing objects and at the same time did not even try to seperat the domains.

You can just effortlessly go from object to string without noticing. It's not that you can cast them, it's that you always do.

In other words, I understand the JavaScript object system good enough to say that it ain't an object system. Because that would imply that you actually have objects. It's more of an object spectrum. You might have an object.

In short, it's aspect oriented programming all over again.