ES2015以前の可変長引数の書き方

LTSのnode 4系ではRest Parametersは使えんのですよね。

'use strict';

function x(a, var_args) {
  const args = Array.prototype.slice.call(arguments, 1);
  
  console.log(a);
  console.log(args);
}

x('a');
x('b', 1);
x('c', 1, 2);
x('d', 1, 2, 3);

可変長の仮引数部分はvar_argsと書いておくのが流儀らしい。

実行結果

a
[]
b
[ 1 ]
c
[ 1, 2 ]
d
[ 1, 2, 3 ]