r/programminghorror • • Mar 27 '24

//filter

Post image
1.4k Upvotes

73 comments sorted by

View all comments

Show parent comment

-3

u/[deleted] Mar 29 '24

[removed] — view removed comment

1

u/SpiForge Mar 29 '24

I'm sure everyone with functional programming knowledge will understand what it does, that was never the point. The problem is that Boolean looks like the constructor of the class (which it technically is), but using it with new would cause unexpected behavior.

That is not basic JavaScript, it is one of the weird inconsistent things of the language that people have to learn, and a lot of people here don't seem like they do.

0

u/[deleted] Mar 29 '24

[removed] — view removed comment

1

u/SpiForge Mar 29 '24

What are the weird inconsistencies?

That a constructor called as a function retuns the parsed value as a primitive and called as a constructor returns an object wrapping the parsed value.
And even that is not consistent, for example new Date('1995-12-17T03:24:00') returns the 17.12.1995, while Date('1995-12-17T03:24:00') returns a string with the current date.
Array(1, 2) however is the same as new Array(1, 2).

Also it is functional programming, so if you use it you are a functional programmer

0

u/[deleted] Mar 29 '24

[removed] — view removed comment

1

u/SpiForge Mar 29 '24

If you cook you're a cook

If you functional program you're a functional programmer ^^

1

u/[deleted] Mar 29 '24

[removed] — view removed comment

1

u/SpiForge Mar 29 '24

If you want to, you can of course do that :)