Ahmed FASIH is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Ahmed FASIH @22

Whenever I think has no more betrayals left to inflict on me, I discover another:

`[4] * 3`, that is, an array containing a number, multiplied by a number, returns… 12, another number.

I think my mistake is thinking JavaScript is a tsundere and some day I’ll get the dere. Maybe JavaScript is the of programming languages—just a giraffe traitor 😤

· Web · 0 · 1

@22 Did you expect that it would output 4, three times?

@bthall No, I actually expected an error to be thrown—with such conviction that I wrote a unit-test assuming it would throw and scratched my head why `tape` was saying it didn't catch any thrown exceptions 😂

@22 😂 I think it works in a similar way as #Rlang deals with rows of numbers being multiplied. Maybe test adding in a second number to the array to see if it'll output both numbers multiplied by 3? 🤓

@bthall Alas, it's not nearly as cool as R. Arithmetic will convert only single-element arrays to scalars. Multiplying a two-element array with a scalar number results in … NaN. Still shaking my head. octodon.social/media/jJWiFWqL_