Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created May 9, 2019 09:40
Show Gist options
  • Save ThaddeusJiang/a1497d870994a9dbc0a13ad4e053dad2 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/a1497d870994a9dbc0a13ad4e053dad2 to your computer and use it in GitHub Desktop.
[easy buggy] JS default value just work for `undefined`
const {
    packageQuantity = 0,
    packageVolume,
  }: {
    packageQuantity: number,
    packageVolume: Object,
  } = batch;
  
// if batch = {
//    packageQuantity: null,
//    packageVolume: any,
//  }
// We can't get `0`.

use ||

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment