JavaScript创建对象的两种方式

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>、
  <script type="text/javascript">
    /*
    * js中的对象:
    *           1、数组
    *           2、函数
    *           3、一般对象
    *           4、js中自带对象
    *             4.1、JavaScript内置对象:Array、Date、Math...
    *             4.2、浏览器对象:window:浏览器对象模型的核心对象
    *                            location:控制URL【地址栏】的对象【取值赋值】
    *             4.3、dom对象:document、body、button...
    *
    * */
    //浏览器 location对象
    //location.href = "http://www.baidu.com";
    // location = "http://www.baidu.com";

    //一般对象
    //方式一
    var stu = new Object();
    stu.name = "jianle";
    stu.age = 20;
    stu.study = function () {
      alert(stu.name + "正在学习...");
      // alert(this.name+"正在学习...");this关键字指向的是调用当前函数对象
    }
    alert(stu.age);
    stu.study();

    //方式二
    var stu = {
      "stuName":"caixukun",
      "stuAge":22,
      "study":function () {
      alert(this.stuName+"is studing...");
      }
    };
    alert(stu.stuAge);
    stu.study();
  </script>
</head>
<body>

</body>
</html>