3 ms·
> how can you know what happens when you call it? Documentation, good API design. Real-world example of a function I call pretty often (which I’m also interest
by minitech 7y ago
> how can you know what happens when you call it?
Documentation, good API design. Real-world example of a function I call pretty often (which I’m also interested in knowing your better alternative to):
const extend = (dest, from) => {
for (const x of from) {
dest.push(x);
}
};
It doesn’t return anything, so I’d say it’s pretty clear its entire purpose is to mutate one argument.
(Non-stack-overflowing version of dest.push(...x), by the way.)