要将第二个参数设置为undefined,只需将其设置为以下内容-
displayFunc(undefined, "Amit");
这是一个将第一个参数设置为“ undefined”时成功显示第二个参数的示例
<!DOCTYPE html>
<html>
<body>
<script>
function displayFunc (p1, p2) {
document.write("Parameter 1 = "+p1);
document.write("<br>Parameter 2 = "+p2);
}
displayFunc(undefined, "Amit");
</script>
</body>
</html>