国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

JavaScript global variables and local variables

Global variables:

  • # Variables that can be used anywhere on the web page (inside and outside functions) are "global variables" variable".

  • Variables defined outside the function are "global variables".

  • Global variables" can be used outside the function or inside the function.

  • "Global variables" are used when the web page is closed. Automatically disappear (release space)

##Local variables:

  • can only be used in functions. Variables used internally are called "local variables".

  • ## "Local variables" are defined inside the function and used inside the function. "Local variables" cannot be accessed outside the function.
  • ##"Local variables" disappear after the function is executed.
  • #
Continuing Learning
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> //定義全局變量 var name = "小明"; function information(){ //定義局部變量 var age = 24; document.write("大家好,我叫"+name+",今年"+age+"歲<br/>"); } //調(diào)用函數(shù) information(); //下面的這行代碼會報錯,說age不存在 //因為age變量是局部變量,函數(shù)執(zhí)行完畢,局部變量就消失了 //document.write("大家好,我叫"+name+",今年"+age+"歲<br/>"); </script> </head> <body> </body> </html>
submitReset Code