Editor Arrow Download Open
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript nested object</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> var myObj = { "commercial": ".com", "network": ".net", "country_domains": { // Nested Object "usa": ".us", "uk": ".uk", "israel": ".il", "australia": ".au" }, "organization": ".org", "government": ".gov" }; document.writeln("commercial domain: " + myObj.commercial); // Outputs .com document.writeln("israel domain: " + myObj.country_domains.israel); // Outputs .il </script> </pre> </body> </html>
  Preview Arrow