编程语言
首页 > 编程语言> > JavaScript [vaynexiao]

JavaScript [vaynexiao]

作者:互联网

js对象

    var obj = {
        user1: {
            'name': 'zhangsan',
            "heigth": '175',
            weight: 155
        }
    }
    console.log(obj); // {user1: {…}, wife: 'alice', age: 13}
    console.log(typeof obj); // object
    console.log(JSON.stringify(obj)); // {"user1":{"name":"zhangsan","heigth":"175","weight":155}}
    console.log(obj.user1); // 同理,也是打印object
    console.log(obj.user1.name); // 属性名 加单引号
    console.log(obj.user1.heigth); // 属性名 加双引号
    console.log(obj.user1.weight); // 属性名 啥都不加

标签:console,log,weight,user1,heigth,JavaScript,obj,vaynexiao
来源: https://blog.csdn.net/vayne_xiao/article/details/122527679