Skip to content

Instantly share code, notes, and snippets.

@savelee
Last active October 7, 2016 08:05
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 savelee/3667a2c6b6e2d21683bf390f29682811 to your computer and use it in GitHub Desktop.
Save savelee/3667a2c6b6e2d21683bf390f29682811 to your computer and use it in GitHub Desktop.
//ES2015 spread operator
var logTech = function(...spread){
//This looks much nicer. Has better performance.
//and contains a true Array.
console.log(spread); // Array [ "extjs", "javascript", "html5" ]
}
logTech("extjs", "javascript", "html5");
//ES5 function arguments
var logTech = function(){
console.log(arguments); // { Arguments: 5 more... }
//Although it looks like an array, it’s not a real array. It's an object.
//So you would do something like this:
var args = Array.prototype.slice.call(arguments, 0);
console.log(args); // Array [ "extjs", "javascript", "html5" ]
}
logTech("extjs", "javascript", "html5");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment