Object Types
ECMAScript
It is actually a collection of data and functions of a group formation. Objects can performnew
to create the name of the object type followed by the operator to be created. CreatedObject
exemplary type of attributes and add and (or) method, you can create custom objects.
Syntax {[key]: [value], ...} is any object from zero to a plurality of sets of key-value pair (attribute name: attribute value) consisting of (attribute names and can not be repeated)
Create an object:
// 方法一
var obj = new Object();
var person = new Object({
name:'Json',
age: 18,
sex: 'man'
})
// 方法二
var obj = {}
var person = {
name: 'Json',
age: 18,
sex: 'man',
1: 100
}
person.name // 获取属性名对应的属性名(对象.属性)
person['age'] // 对象[属性名],属性名是数字或者字符串格式
person.height // 如果当前属性名不存在,默认的属性值是undefined
person[1] // 如果属性名是数字,则不能使用点的方式获取属性值
Each Object
instance has (Method prototype chain) following properties and methods
constructor
hasOwnProperty(propertyName)
For detecting whether there is a current object instance attributes givenisPrototypeOf()
propertyIsEnumerable(propertyName)
toLocaleString()
toString()
valueOf()