💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 自定义对象 [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> ~~~