多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 自定义对象 [TOC] ## 定义并创建对象实例 ~~~ <script> // 定义并创建对象 people = new Object(); people.name = 'rose'; people.age = 25; console.log('name: '+people.name +' & age: '+people.age); </script> ~~~ 或者 ~~~ <script> people = {name:'rose',age:25}; console.log('name: '+people.name +' & age: '+people.age); </script> ~~~ ## 使用函数来定义对象,然后创建新的对象实例 ~~~ <script> function people(name,age){ this.name = name; this.age = age; } son = new people("rose",25); console.log('name: '+son.name +' & age: '+son.age); </script> ~~~