SOURCE

'use strict';

var xiaoming = {
    name: '小明',
    birth: 1990,
    school: 'No.1 Middle School',
    height: 1.70,
    weight: 65,
    score: null
};
console.log(xiaoming.name);
console.log(xiaoming.weight);

var xiaohong = {
    name: '小红',
    'middle-school': 'No.1 Middle School'
};
console.log(xiaohong['middle-school']);
//新增一个age属性
xiaohong.age = 19;
console.log(xiaohong.age);
//删除一个属性
delete xiaohong.age;
console.log(xiaohong.age);

//用in操作符检测对象是否拥有某一属性
console.log('name' in xiaohong);
console.log('grade' in xiaohong);
console.log('toString' in xiaohong); //true

//用in判断一个属性存在,但是对象继承object也会判断到
console.log('hasOwnProperty()方法判断是否是对象自身拥有的')
console.log(xiaohong.hasOwnProperty('name'));
console.log(xiaohong.hasOwnProperty('toString'))
console 命令行工具 X clear

                    
>
console