jsでの引数の初期値

  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>jsでの引数の初期値</title>
  6. <style type="text/css">
  7. table
  8. {
  9.   border-collapse:collapse;
  10.   margin:0;
  11. }
  12. th, td
  13. {
  14.   text-align:left;
  15.   vertical-align:top;
  16.   padding:3px 8px;
  17.   font-weight:normal;
  18.   border:1px solid #ccc;
  19. }
  20. th
  21. {
  22.   background:#f3f3f3;
  23. }
  24. </style>
  25. <body>
  26. <h1>jsでの引数の初期値</h1>
  27. <script type="text/javascript">
  28.   function initArg(arg)
  29.   {
  30.     arg = arg || "りんご";
  31.     document.write(arg);
  32.   }
  33.   
  34.   initArg();
  35.   
  36. </script>
  37. <div style="font-size:10pt;text-align:right;margin-top:0.5em;">
  38. <a href="//tips.recatnap.info/" target="_top">PCスキルの小技・忘却防止メモ</a> -
  39. <a href="//tips.recatnap.info/wiki/" target="_top">PCスキルの小技・忘却防止メモのまとめ(wiki)</a>
  40. </div>
  41. <div style="font-size:10pt;text-align:center;margin-top:0.5em;padding:0.5em;border-top:1px solid #ccc;">
  42. Copyright &copy; 2009 by PCスキルの小技・忘却防止メモ. All rights reserved.
  43. </div>
  44. </body>
  45. </html>