js创建对象
实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> </body> </html> <script type="text/javascript"> //内置构造函数创建对象 var a=new Object(); a.name="aaa"; a.age="1"; console.log(a); //字面量创建对象 var b = {}; b.name="bbb"; b.age="2"; console.log(b); </script>
运行实例 »
点击 "运行实例" 按钮查看在线实例