Call ordinary function, constructor, method of objects - JS Advanced

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta charset="utf-8">
 5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 6 <title>函数的调用方式</title>
 7 </head>
 8 <script>
. 11F1 () {
function10ordinary function calls directly ---//9     
                    the console.log ( " putonghanshu " );
 12 is         }
 13 is         F1 ();
 14      // constructor is invoked via new --- 
15         function Fl () {
 16             the console.log ( " gouzaohanshu " )
 . 17         }
 18 is         var F =  new Fl ();
 . 19  
20 is      // method --- object method () object;. 
21 is         function the Person () {
 22 is             the this .play =  function () {
 23 is                 the console.log ( "Person is playing")
24            };
25        }
26        var per = new Person();
27        per.play();
28 
29 </script>
30 <body>
31 </body>
32 </html>

 

Guess you like

Origin www.cnblogs.com/sylys/p/11579052.html