yuuka_maniaの日記: ... three dot in Javascript 2
日記 by
yuuka_mania
関数宣言での、 ... は、 rest parameters というらしい。
% node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> function x(args) {
... console.dir(args);
... }
undefined
> function xx(...args) {
... console.dir(args);
... }
undefined
> x(1, 2, 3);
1
undefined
> xx(1, 2, 3);
[ 1, 2, 3 ]
undefined
>
ちなみに (スコア:1)
それ以外の場所に現れる...はスプレッド構文という。これとかPerlの記号の意味とか、名前知らないと検索で詰むやつ勘弁してほしい
Re: (スコア:0)
パイソンの可変長引数とか可変長名前付き引数もそんな感じですね。