자바스크립트에서 선택적 함수 매개변수를 선언하려면 "기본" 인수를 사용하십시오.
예시
다음 코드를 실행하여 선택적 매개변수를 선언할 수 있습니다. −
<html>
<body>
<script>
// default is set to 1
function inc(val1, inc = 1) {
return val1 + inc;
}
document.write(inc(10,10));
document.write("<br>");
document.write(inc(10));
</script>
</body>
</html>