<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JavaScript定义对象</title> </head> <body> <!--JavaScript定义对象的2代码种风格和对象属性有两种寻址方式--> <script> var person={firstname:"王",lastname:"鹏鹏",age:22}; document.write(person.lastname+"<br />"); document.write(person['lastname']+"<br />"); document.write(person['age']+"<br />"); </script> <script> var person={ firstname:"王", lastname:"梦梦", age:21 }; document.write(person.lastname+"<br />"); document.write(person["lastname"]+"<br />"); document.write(person['age']+"<br />"); </script> </body> </html>
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-09-30 08:48:51