Named arguments in JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
README.md
namedArgs.js
package.json

README.md

named-args

Ever wish JavaScript had named arguments?

function sortableName(first, middle, last) {
  return last + ', ' + first + ' ' + middle;
}

sortableName.withArgs({
  last: 'Smith',
  first: 'Peter',
  middle: 'M'
});
// => 'Smith, Peter M'

Ever wish that arguments were object-like instead of array-like?

function f(x, y, z) {
  console.log(arguments.named());
}

f(1, 2, 3);
// => { x: 1, y: 2, z: 3 }

There you go. Don't say I never gave you anything.