Null-coalescing default values in destructuring

guest271314 guest271314 at gmail.com
Sat May 11 16:19:51 UTC 2019


Slightly less code (still un-golfed as that does not appear to be the
stated requirement described at OP) using the same/similar pattern.

let input_json_string = `{"z":null}`;
const convertJSONNullToUndefined = json => {
  const o = JSON.parse(json);
  for (const key in o) if (o[key] === null) o[key] = void 0;
  return o
}

convertJSONNullToUndefined(input_json_string); // do destructuring stuff
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190511/823dea15/attachment.html>


More information about the es-discuss mailing list