Skip to content

Instantly share code, notes, and snippets.

@rohan-paul
Last active October 21, 2016 14:53
Show Gist options
  • Save rohan-paul/4d7ebc874938659831d1196d312eb46e to your computer and use it in GitHub Desktop.
Save rohan-paul/4d7ebc874938659831d1196d312eb46e to your computer and use it in GitHub Desktop.
function myFunc() {
return Array.prototype.slice.call(arguments);
// args is now a real Array, so can use the sort() method from Array
}
console.log(myFunc('USA', 'UK', 'India'));
console.log(myFunc('USA', 'UK', 'India').sort());
// Will output =>
// [ 'USA', 'UK', 'India' ]
// [ 'India', 'UK', 'USA' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment