Created
June 30, 2015 23:42
-
-
Save chuck0523/b26242e552db61a60bc8 to your computer and use it in GitHub Desktop.
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
//Spread operator | |
//配列の前に...をつけることで展開できる。 | |
var arr = [3, 4, 5]; | |
var nums = [1, 2, ...arr, 6, ...[7]]; | |
console.log(nums); | |
//[1, 2, 3, 4, 5, 6, 7] | |
//[3,4,5]と[7]が展開されている | |
//applyメソッドを使用しなくても良い。 | |
function f(x, y, z) { | |
console.log(x, y, z); | |
} | |
var args = [1, 2, 3]; | |
//ES5 | |
f.apply(null, args); //1 2 3 | |
//ES6 | |
f(...args); //1 2 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment