4 ms·
[1,2,3] + [4,5,6] An addition operation over two numerical vectors of length 3. I would expect the result to match its inputs and provide a numerical vector o
by realo 5y ago
[1,2,3] + [4,5,6]
An addition operation over two numerical vectors of length 3.
I would expect the result to match its inputs and provide a numerical vector of length 3.
Thus: [5, 7, 9]
- fenomas 5y agoThe issue there is that arrays aren't first class types in JS, they're just objects with numeric property names. So if applying an operator to arrays spread the operation across all the elements that way, it would imply that the same should happen generally for all object properties, with whatever weird implications that would entail. a.foo = 1 b.foo = 'there' a + b // { foo: '1there' } ?
- meowface 5y agoWhat language has this behavior by default?
- DangitBobby 5y agoFortran :)