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] 来写。
本文标题:es6基础语法-003
本文链接:https://www.haomeiwen.com/subject/ndftsxtx.html
网友评论