javascript对象定义及对象调用

javascript对象用{}

可以存放任意类型数据

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
       var use={
          nane:'xiaoming',  //字符串
          age:12,  //数字
          marray:true, //布尔类型
          jobs:['it','teacher']  //数组
          enjoy:function(){  //函数
              return 'play'
          }
          contaiter:{  //对象
             froned:'www.96net.com.cn',
             houend:['php','java']
          }
       }
   </script>
</body>
</html>

2,对象调用

user.name 

posted @ 2024-02-20 19:27  学无边涯  阅读(3)  评论(0编辑  收藏  举报