JavaScript中函数参数的默认参数是什么?

默认参数可以轻松处理功能参数。您可以轻松设置默认参数,以允许使用默认值初始化形式参数。仅当未传递任何值或未定义时,才有可能。

示例

<html>
   <body>
      <script>
         //默认设置为1-
         function inc(val1, inc = 1) {
            return val1 + inc;
         }
         document.write(inc(10,10));
         document.write("<br>");
         document.write(inc(10));
      </script>
   </body>
</html>