js之属性操作重点

<script>
        var person = {
            name:"Tom",
            age:18,
            "shen-gao":180,  // 含有特殊符号必须用引号
            slogn:function(){
                for(let i = 0;i < 10;i++){
                    console.log(name + "的口号");
                }
            },
            son:{
                name:"xiaoxiaoming am i"
            }

        };
        console.log(person.name); // Tom ,不用引号的属性,可以直接点出来
        // console.log(person.shen-gao); // 含有特殊符号的属性直接点出来会报错
        console.log(person["shen-gao"]); // 180
    
        var xiaoxiaoming = person.son;
        delete person.son;  
        console.log(xiaoxiaoming); // xiaoxiaoming am i
    </script>
Last modification:June 15th, 2019 at 11:59 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment