私は次の機能を持っています
//simple function with parameters and variable
function thirdfunction(a,b,c,d){
console.log("the value of a is: " + a);
console.log("the value of b is: " + b);
console.log("the value of c is: " + c);
console.log("the value of d is: " + d);
console.log("the arguments for each values are: " + arguments);
console.log("the number of arguments passed are: " + arguments.length);
}
console.log("no parameter values are passed");
thirdfunction();
console.log("only a and b parameter values are passed");
thirdfunction(1,2);
ただしarguments
、テキストを連結すると、渡された値が表示されない場合the arguments for each values are:
。何故ですか?
Googleのコンソールからの出力は、連結すると次のようになります。
no parameter values are passed
the value of a is: undefined
the value of b is: undefined
the value of c is: undefined
the value of d is: undefined
the arguments for each values are: [object Arguments]
the number of arguments passed are: 0
only a and b parameter values are passed
the value of a is: 1
the value of b is: 2
the value of c is: undefined
the value of d is: undefined
the arguments for each values are: [object Arguments]
the number of arguments passed are: 2
連結しない場合、次の値が渡されます。
no parameter values are passed
the value of a is: undefined
the value of b is: undefined
the value of c is: undefined
the value of d is: undefined
[]
the number of arguments passed are: 0
only a and b parameter values are passed
the value of a is: 1
the value of b is: 2
the value of c is: undefined
the value of d is: undefined
[1, 2]
the number of arguments passed are: 2
編集
質問が反対票を投じられた理由はわかりませんが、私が抱えている問題は、ステートメントを使用するとconsole.log("the arguments for each values are: " + arguments);
コンソールの出力が出力されるということです。console.log("the arguments for each values are: " + arguments);
ただし、ステートメントを渡すconsole.log(arguments);
と、コンソールの出力は[]
または[1, 2]
?