Skip to content

Instantly share code, notes, and snippets.

@itaditya
Last active August 9, 2020 07:28
Show Gist options
  • Select an option

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

Select an option

Save itaditya/f175d3631e05a8a548c2ba39b1982174 to your computer and use it in GitHub Desktop.
(Blog) Why named arguments are better than positional arguments
// With positional args we had to add a null in between
function greetPos(firstName, middleName, lastName) {}
greetPos('Aditya', null, 'Agarwal');
// With named args you just provide firstName & lastName.
function greetNamed({ firstName, middleName, lastName } = {}) {}
greetNamed({ firstName: 'Aditya', lastName 'Agarwal' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment