Blogger Information
Blog 40
fans 1
comment 0
visits 32433
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
对象的知识点——2019年1月16日
李明伟的博客
Original
567 people have browsed it

对象的知识点(文档对象类型)

对象是属性的无序集合

类似于c语言中的结构体

代码示例:

代码定义

var obj = {
    x:10,
    y:20,
    z:30
}

取其中的元素——对象名.元素名

obj.x
10
obj.y
20

对象中的元素名可以是非法的

var obj ={'h-a':100,'a b c':120}

但这种情况下取元素需要使用'[' ']'而无法使用上一种方法

obj.a b c
VM1630:1 Uncaught SyntaxError: Unexpected identifier
obj[a b c]
VM1663:1 Uncaught SyntaxError: Unexpected identifier
obj['a b c']
120

总结:对象的构造类似于结构体,但细节上有区别

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!