<html>
<head>
    <title></title>
    <script>
    //create array 
        var beatles = new Array("1","2","3","4");
        beatles = Array("1","2","3","4");
        beatles = ["1","2","3","4"];
        alert(beatles);

    // create object
        var person = Object();
        person.name = "mguo";
        person.gentle = "male";

        person =  {name:"mguo",gentle:"male"};
        alert(person.name);

    // 未用var声明的变量看做全局变量

    var total = 50;
    function square(num){
        total = num *  num;
        return total;
    }

    function square_(num){
        var total = num *  num;
        return total;
    }

    var number = square(20);
    alert(total);
    total = 50;
    var number_ = square_(20);
    alert(total);


    </script>
</head>
<body>

</body>
</html>

 

相关文章:

  • 2021-12-27
  • 2021-07-23
  • 2021-06-27
  • 2021-10-27
  • 2021-10-15
  • 2021-12-21
  • 2021-11-25
  • 2021-09-25
猜你喜欢
  • 2021-11-14
  • 2021-08-21
  • 2022-12-23
  • 2021-12-10
  • 2021-05-30
  • 2021-12-28
  • 2021-08-09
相关资源
相似解决方案