Skip to content

Instantly share code, notes, and snippets.

@itaditya
Created August 1, 2020 14:42
Show Gist options
  • Select an option

  • Save itaditya/fe310c818b02319c889f415d27897ed4 to your computer and use it in GitHub Desktop.

Select an option

Save itaditya/fe310c818b02319c889f415d27897ed4 to your computer and use it in GitHub Desktop.
(Blog) Why named arguments are better than positional arguments
// positional args
function myCustomParseInt(item, radix) {
return parseInt(item, radix);
}
// old implementation of named args
function myCustomParseInt(objArgs) {
return parseInt(objArgs.item, objArgs.radix);
}
// named args with destructuring
function myCustomParseInt({ item, radix }) {
return parseInt(item, radix);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment