不定参数和默认参数

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") {
returnLions and ${animals2} and ${animals3}! Oh my!;
}

上一篇 下一篇

猜你喜欢

热点阅读