Skip to content

Instantly share code, notes, and snippets.

@erikpantzar
Last active October 14, 2016 18:50
Show Gist options
  • Save erikpantzar/97bd9de48a192e3389361216d62d1f49 to your computer and use it in GitHub Desktop.
Save erikpantzar/97bd9de48a192e3389361216d62d1f49 to your computer and use it in GitHub Desktop.

Do we accept this pattern?

Check this url: Babel: Defaultparams => es6 to es5

Wanted es6 feature

function productInMarket(productMarkets = '', userMarket= '') {
  if (productMarkets.length > 0) {
    return productMarkets.indexOf(userMarket) > -1;
  } else {
    return false;
  }
}

Compiled to es5

function productInMarket() {
  var productMarkets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var userMarket = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

  if (productMarkets.length > 0) {
    return productMarkets.indexOf(userMarket) > -1;
  } else {
    return false;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment