javascript中普通函数的使用介绍

复制代码 代码如下:

  <html>

  <head>

  <title>javascript中普通函数的使用</title>

  <script>

  function show(){

  document.write("show函数被调用" + "<br/>");

  return 10;

  }

  var hello = show();//show()函数被调用,将返回值赋值给hello变量。如果函数没有返回值,则返回undefined

  document.write(hello + "<br/>");//10

  var hello2 = show;//show和hello2指向同一个函数

  document.write(hello2 + "<br/>");//打印出show的函数体

  hello2();//等同于调用show()函数

  </script>

  </head>

  <body>

  </body>

  </html>