3 ms·
I sure hope `someThing` is never `undefined`, for your sake.
by jakear 4y ago
I sure hope `someThing` is never `undefined`, for your sake.
- RedShift1 4y agoAny cloning happens on data retrieved from an API, which is always JSON, and cannot contain undefined by definition.
- grensley 4y agoJust chuck a check in front of it
- dspillett 4y agoThat seems to be a logical thing to ensure has been validated before this code is run, so no need to complicate the simple example in a HN post?
- jakear 4y ago> avoid all the mess that comes with trying to clone anything else than primitives types is an odd way to suffix code that will throw a SyntaxError when handed a primitive type.
- Gare 4y agoOr NaN or Infinity.
- ravenstine 4y agoThere's this really nifty concept called "guarding" that helps with recovering from that sort of thing.