对象
var 对象名={
属性名:属性值,
属性名:属性值,
属性名:属性值,
属性名:属性值,
}
定义了一个persion的对象
var persion ={
name:"xxxxxx",
age:123,
sex:'男',
score:100
}
js中的对象,{…} 表示一个对象,键值对描述属性xxxxxx 隔开,最后一个属性不加逗号。
1.对象赋值
persion.name="LLLL"
"LLLL"
pserion.name
"LLLL"
2.使用一个不存在的对象属性,不会报错, undefined
psersion.hhhhh
undefined
psersion
3.动态删除对象的属性 通过delete 删除对象的属性
delete.persion.name
true
persion
4.动态添加属性 直接给新的属性添加
persion.hhh="haha"
haha
persion
5.判断一个属性是否在这个对象里面 xxxx in xxx
'age' in persion
true
//继承
'tostring' in persion
true
6.判断一个属性是否是这个对象自身是否拥有 使用: hasOwnproperty()
persion.haOwnProperty('tostring')
false
persion.haOwnProperty('age')
true