JavaScriptの複雑なデータ構造(連想記憶配列)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta name="GENERATOR" content="JustSystems Homepage Builder Version 18.0.14.0 for Windows"> <title>JavaScript練習中!</title> </head> <body background="y8b.gif"> <?php require_once ("newpage8.php"); print $APPTITLE; MyTitlePrint("連想記憶配列、実験開始!"); ?> <script> <!-- //ここにJavaScriptを書くよー const superHeroes = { "squadName" : "Super hero squad", "homeTown" : "Metro City", "formed" : 2016, "secretBase" : "Super tower", "active" : true, "members" : [ { "name" : "Molecule Man", "age" : 29, "secretIdentity" : "Dan Jukes", "powers" : [ "Radiation resistance", "Turning tiny", "Radiation blast" ] }, { "name" : "Madame Uppercut", "age" : 39, "secretIdentity" : "Jane Wilson", "powers" : [ "Million tonne punch", "Damage resistance", "Superhuman reflexes" ] }, { "name" : "Eternal Flame", "age" : 1000000, "secretIdentity" : "Unknown", "powers" : [ "Immortality", "Heat Immunity", "Inferno", "Teleportation", "Interdimensional travel" ] } ] } document.write(superHeroes.homeTown + "<BR>"); document.write(superHeroes['members'][1]['powers'][2]); document.close(); //--> </script> <?php print "$APPFOOTER"; ?> <p><a href="JavaScriptMenu.php">JavaScriptMenuへ</a></p> </body> </html> |
ネットから拾ったもので、そのままです。後から気が付きましたが、連想記憶配列ですね。