JS --对象

直接上例子,不解释

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html" charset="utf-8">
    <title> This is my HTML</title>
</head>
<body>
    <script type="text/javascript">
      /***创建对象***/
      user = new Object();
      user.name = "panda";
      user.gender = "女";
      user.age = "27";

      /***访问对象属性***/
      /***语句为:objectName.propertyName***/
      document.write(user.name + "已经" + user.age +"岁了");  
    </script>
</body>
</html>


你可能感兴趣的:(JS --对象)