1. 程式人生 > >js基礎-物件字面量(json存在的物件)

js基礎-物件字面量(json存在的物件)

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title></title>
      <!--物件字面量(json格式的物件)-->
      <script type="text/javascript" >
    var obj={
            name:"小明",
    age:18,
    obj2:{
        name:"沙和尚"
    }
}
         console.log(obj.name)
         console.log(obj.obj2.name)
</script>
</head>
<body>
</body