Skip to content

Instantly share code, notes, and snippets.

@BenBestmann
Last active July 1, 2016 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenBestmann/5982118331fd87767986fb44970a68a5 to your computer and use it in GitHub Desktop.
Save BenBestmann/5982118331fd87767986fb44970a68a5 to your computer and use it in GitHub Desktop.
Simulate named parameters in ES5 using an object literal, passing multiple parameters as a single actual parameter.
function selectEntries(options) {
options = options || {};
var start = options.start || 0;
var end = options.end || -1;
var step = options.step || 1;
// function implementation
}
selectEntries({ start: 3, end: 20, step: 2 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment