亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

?????? ???

???? ?????

???? ?? ???? ??? ??? ????. ?? ??? ?? ???(?? ??)? ??? ??? ???? ????? ??? ??? ???? ?????. . ???? ??:

  1. ?? ??? ?? ??? ??? ??? ? ??????.

  2. ???? ??? ??? ? ???? ???? ?? ?? ?????.

  ??? ??? Javascript? ?? ??? ??? ?????. ?, ?? ??? ?? ???? ?? ??? ?? ??? ?????. ?? ??? ?? ??? ?? ?? ??, ???? ? ?? ??? ???? ?? ??? ??? ?? ?? ??? ???? ? ????. ??? ?? ?? ? ??? ?? ???? ?? ?? ???? ???? ???? ?????.


???? ???? ???? ?? ??

? ?? ?? ??

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
    <script type="text/javascript">  
          function Circle(r) {  
            this.r = r;  
           }  
           Circle.PI = 3.14159;  
           Circle.prototype.area = function() {  
             return Circle.PI * this.r * this.r;  
           }  
          var c = new Circle(1.0);     
           alert(c.area());   
    </script>  
</head>  
<body>  
</body>
</html>

??? ?? ??? ??? ?? ??? ??? ? ?? ??? ??? ????.

? ?? ?? ??

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
    <script type="text/javascript">  
       var Circle = function() {  
         var obj = new Object();  
         obj.PI = 3.14159;  
        obj.area = function( r ) {  
             return this.PI * r * r;  
           }  
            return obj;  
         }  
        var c = new Circle();  
         alert( c.area( 1.0 ) );  
    </script>  
</head>  
<body>  
</body>
</html>

? ?? ??? ??? ???? ??? ??? ??? ???? ????.

? ?? ?? ??

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
    <script type="text/javascript">  
       var Circle = new Object();  
            Circle.PI = 3.14159;  
            Circle.Area = function( r ) {  
             return this.PI * r * r;  
            }  
           alert( Circle.Area( 1.0 ) );  
    </script>  
</head>  
<body>  
</body>
</html>

? ??? ?? ? ?????, ? ??? ?? ?? ?? ??? ??? ???? ???? ????.

??? ? ?? ??

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
    <script type="text/javascript">  
         var Circle={  
           "PI":3.14159,  
            "area":function(r){  
               return this.PI * r * r;  
              }  
           };  
          alert( Circle.area(1.0) );  
    </script>  
</head>  
<body>  
</body>
</html>

? ??? ????? ???? ?? ?????. var obj = {}? ? ??? ???? ????


Javascript ???? ??

?? ???? ???? ?? ?? ? ? ????. ?? ??, ?? ?? ?? ???? ?????? ? ???, ??? ?? ???? ???? ???? ?? ???? ??? ?? ???? ??????.

1. ?? ?? ?? ??

2. ?? ??

3. ?? ??? ? ??


JavaScript ?? ???? ??? ?? ??? ??? ? ????.

?? JavaScript??? ?? ??? ? ?? ??? ???? ? ????.

JavaScript? ?? ??? ?????. ??? ??? ?? ??? ?? ??? ??? ? ????.

? ??? ?? ?? plus()? ?? ??? ??? ??? ???? ? ????.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php中文網(wǎng)(php.cn)</title>
</head>
<body>
<p id="demo">0</p>
<script>
document.getElementById("demo").innerHTML = add();
function add() {
var counter = 0;
    function plus() {counter += 1;}
    plus();    
    return counter; 
}
</script>
</body>
</html>

???? plus() ??? ???? ? ??? ??? ???? ??? ? ????.

?? counter = 0? ? ?? ????? ?? ???.

???? ??? ?????.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php中文網(wǎng)(php.cn)</title>
</head>
<body>
<button type="button" onclick="myFunction()">計數(shù)!</button>
<p id="demo">0</p>
<script>
var add = (function () {
    var counter = 0;
    return function () {return counter += 1;}
})();
function myFunction(){
    document.getElementById("demo").innerHTML = add();
}
</script>
</body>
</html>

?? ??

?? add? ?? ?? ??? ?? ?? ?? ?????.

?? ?? ??? ? ?? ?????. ???? 0?? ?????. ?? ???? ?????.

add ??? ??? ??? ? ????. ?? ??? ?? ?? ???? ???? ?? ???? ????? ????.

?? JavaScript ????? ???. ??? ?? ??? ?? ? ?? ????.

???? ?? ??? ??? ???? add ???? ???? ??? ? ????.

???? ?? ??? ?? ??? ?? ?? ?? ?? ??? ??? ? ?? ?????.

???? ??
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> function buildFunctions(){ var funcArr = []; for(var i = 0; i < 3; i++){ funcArr.push((function(j){ return function(){ console.log(j); }; }(i))); } return funcArr; } var fs = buildFunctions(); fs[0](); //0 fs[1](); //1 fs[2](); //2 </script> </head> <body> <p>請在瀏覽器中點擊 F12 來觀察結果</p> </body> </html>