this post was submitted on 24 Nov 2025
603 points (89.2% liked)
Programmer Humor
27690 readers
357 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Here’s my thought process: plus is for numbers and strings, so it’s gonna convert the arrays to either numbers or strings. If it converts them to 0, the answer is 0, if it converts them to 1, the answer is 2, if it converts them to strings, the answer is “12”.
You know what I didn’t say? [1,2]. Because plus is not for array concatenation. The question is meant to make you think you’ll get [1,2], because why else would you use plus on arrays?
In a language that uses plus for concatenation, you’ll see that kind of code all over, and know what you’ll get. But you never see that in JavaScript, because that’s not how we concatenate arrays.