###### tags:`ALPHACampWeek6_學期2-2` # 去最外層陣列方式:for...of迴圈&&展開運算子 ## for...of迴圈 - 示範一 ```jsx= const movies = []; axios.get(INDEX_URL).then(response =>{ for(const movie of response.data.results){ movies.push(movie); } }) ``` ## 展開運算子 * 示範一 ```jsx= const movies = []; axios.get(INDEX_URL).then(response => { movies.push(...response.data.results); console.log(movies); }) ``` - 示範二 ```jsx= function sum(x, y, z) { return x + y + z; } const numbers = [1, 2, 3]; console.log(sum(...numbers)); // expected output: 6 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up