function animals(...types){
console.log(types)
}
animals('cat', 'dog', 'fish') //["cat", "dog", "fish"]
传入的参数个数可能不同,但需要根据参数的个数来执行不同的函数片段。
如果按照es5 的语法来写的话就需要使用arguments[0] 来写。
function animals(...types){
console.log(types)
}
animals('cat', 'dog', 'fish') //["cat", "dog", "fish"]
传入的参数个数可能不同,但需要根据参数的个数来执行不同的函数片段。
如果按照es5 的语法来写的话就需要使用arguments[0] 来写。