不定参数和默认参数
2017-09-05 本文已影响4人
echo_me
不定参数
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") {
return
Lions and ${animals2} and ${animals3}! Oh my!;
}