기능에 다양한 인수를 사용하려면 인수 개체를 사용하십시오.
예시
JavaScript에서 함수에 대한 인수를 구현하기 위해 다음 코드를 실행할 수 있습니다.
실시간 데모
<html>
<body>
<script>
function functionArgument(val1, val2, val3) {
var res = "";
res += "Expected Arguments: " + functionArgument.length;
res += "<br />";
res += "Current Arguments : " + arguments.length;
res += "<br />";
res += "Each argument = "
for (p = 0; p < arguments.length; p++) {
res += "<br />";
res += functionArgument.arguments[p];
res += " ";
}
document.write(res);
}
functionArgument(20, 50, 80, "Demo Text!","Hello World", new Date())
</script>
</body>
</html>