1. 程式人生 > >呼叫函式返回值

呼叫函式返回值

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>

</head>
<body>


<!--  利用原生js使圖片自適應居中-->
<script>
window.onload=function(){
  var param1 = sayHello("hello");
  console.log(param1);
  alert(param1);

  var
param2 = sayBye("say","Bye"); console.log(param2); console.log(param2.a); console.log(param2.b); } //定義的函式值只有一個 function sayHello( text ){ var hello = text; console.log(hello); return hello; } //定義的函式值有多個 function sayBye( say, Bye ){ var saytext = {a: say, b: Bye}; console.log(saytext); return
saytext; }
</script> </body> </html>

這裡寫圖片描述