1 <script type="text/javascript">
 2     /*反射*/
 3     typeof flight.number     //'number'
 4     typeof flight.status    //'string'
 5     typeof flight.arrival    //'object'
 6     typeof flight.manifest    //'undefined'
 7 
 8     typeof flight.toString     //'function'
 9     typeof flight.constructor//'function'
10 
11     flight.hasOwnProperty('number')        //true
12     flight.hasOwnProperty('constructor')//false
13 
14     /*减少全局变量的污染*/
15     全局变量削弱了程序的灵活性,尽量避免
16     var Mapp={};
17     Mapp.stooge={
18         "first-name":"Joe",
19         "last-name":"Howard"
20     };
21     Mapp.flight={
22         airline:"Oceanic",
23         number:815,
24         departure:{
25             IATA:"SYD",
26             time:"2004-09-22 14:55",
27             city:"Sydney"
28         },
29         arrival:{
30             IATA:"LAX",
31             time:"2004-09-23 10:42",
32             city:"Los Angeles"
33         }
34     };
35     </script> 

 

相关文章:

  • 2021-07-31
  • 2022-12-23
  • 2021-04-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-05
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案