不定参数和默认参数

不定参数

function test(a, ...b){
console.log(a);
console.log(b);
}
>test("echo","e","c","h");
< echo
["e", "c", "h"]

默认参数

function animalSentence(animals2="tigers", animals3="bears") {
returnLions and ${animals2} and ${animals3}! Oh my!;
}

你可能感兴趣的:(不定参数和默认参数)