Last active
October 7, 2016 08:05
-
-
Save savelee/3667a2c6b6e2d21683bf390f29682811 to your computer and use it in GitHub Desktop.
Rest parameters & Spread Operator - https://www.leeboonstra.com/developer/sencha-ecmascript-2015/
This file contains 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
//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"); |
This file contains 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
//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