Noticed a small quirk today in the JavaScript spread syntax: If you have three values:
const a = null;
const b = { x: 1 };
const c = [2];
Then the spread syntax for objects will work just fine
expect({ ...a, ...b }).toStrictEqual({ x: 1 });
While the spread syntax for arrays will throw a TypeError: a is not iterable:
expect([...a, ...c]).toThrow();
So the handling of null is different for these two cases. Interestingly
typeof null seems to return object, while Object.keys(null) throws
TypeError: Cannot convert undefined or null to object.
At the same time, typeof undefined === 'undefined' but the same seems to
happen for a = undefined for the spread syntax (error for arrays, fine for objects).