Last active
August 9, 2020 07:28
-
-
Save itaditya/f175d3631e05a8a548c2ba39b1982174 to your computer and use it in GitHub Desktop.
(Blog) Why named arguments are better than positional arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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