标签:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <ul> <li id="bj" name="beijing">北京</li> </ul> </body> <script language="JavaScript"> /** * 案例一 * {key:value,key:value} * * class Person{ * String firstname = "张"; * String lastname = "三丰"; * Integer age = 100; * } * * Person p = new Person(); * System.out.println(p.firstname); */ var p = [{firtstName:"zhang",lastName:"sanfen",age:100},{firtstName:"zhang",lastName:"sanfen",age:10}]; alert(p[0].lastName + " and " + p[1].age); var p = {"name":["zhang",{sanfen:"sanfen11"}]}; alert(p.name[1].sanfen); </script> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>insertBefore.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <body> <ul> <li id="bj" name="beijing">北京</li> </ul> </body> <script language="JavaScript"> /** * 案例二 * [{key:value,key:value},{key:value,key:value}] * */ var array = [{name:‘张‘,age:19},{name:‘李‘,lastname:‘天一‘,age:17}] alert(array[0].name); alert(array[1].age); </script> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>insertBefore.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <body> <ul> <li id="bj" name="beijing">北京</li> </ul> </body> <script language="JavaScript"> /** * 案例三 * { * "param":[{key:value,key:value},{key:value,key:value}] * } * * */ var obj = {name:‘林夕‘,family:[{name:‘双江‘,age:75},{name:‘skyone‘,age:17}]}; alert(obj.family[1].name) </script> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>insertBefore.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <body> <ul> <li id="bj" name="beijing">北京</li> </ul> </body> <script language="JavaScript"> /** * 案例四 * { * "param1":[{key:value,key:value},{key:value,key:value}], * "param2":[{key:value,key:value},{key:value,key:value}], * "param3":[{key:value,key:value},{key:value,key:value}] * } */ var obj = { "man":[{name:‘张无忌‘,age:19},{name:‘张翠山‘,age:40}], "woman":[{name:‘赵敏‘,age:16},{name:‘芷若妹子‘,age:20},{name:‘灭绝师太‘,age:18}], "妖":[{name:‘轻易福王‘,age:19},{name:‘金毛狮王‘,age:55}] } alert(obj.妖[1].age); </script> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>insertBefore.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <body> <ul> <li id="bj" name="beijing">北京</li> </ul> </body> <script language="JavaScript"> /** * 案例五: * Person { "key":"value", "key":"value", "key":{"key":"value","key":"value"}, "key":[ {"key":"value","key":"value"}, {"key":"value","key":"value"} ] } */ var obj = { 刘备:‘孙上香‘, 孙权:‘大乔‘, 曹操:{name1:‘赤兔马‘,name2:‘小巧‘,name3:‘貂蝉‘}, 小宝:[ {name:‘双儿‘,age:19}, {name:‘建宁公主‘,age:15} ] } alert(obj.小宝[1].name) </script> </html>
标签:
原文地址:http://my.oschina.net/u/2356176/blog/425356