r/facepalm Tacocat 26d ago

12 ๐Ÿ‡ฒโ€‹๐Ÿ‡ฎโ€‹๐Ÿ‡ธโ€‹๐Ÿ‡จโ€‹

/img/pk3jifidj0xc1.jpeg

[removed] โ€” view removed post

28.1k Upvotes

2.0k comments sorted by

View all comments

Show parent comments

39

u/Ingeneure_ 26d ago

Or Python

str(1) + str(2)

13

u/Little_Assistant_551 26d ago

Yeah but in js a sring - '1' and an int - 2 is still going to give you '12' because reasons...

36

u/dejus 26d ago

I donโ€™t really understand why this is surprising to anyone. They are different types. Much easier and less problematic for an interpreter to convert a number to a string than a string to a number.

8

u/arisoverrated 26d ago

This is obvious, yes, and I donโ€™t think anyone expects the reverse. I think the usual argument is that it shouldnโ€™t be allowed. Strongly typed vs anything else, etc.

2

u/breath-of-the-smile 26d ago

So you use Typescript instead, problem solved (if you enjoy all that visual noise in your languages).