Editor Arrow Download Open
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript object creating accessing</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> var myObj = {}; // indicates an Object is created myObj.commercial = ".com"; myObj.network= ".net"; myObj.organization= ".org"; myObj.government= ".gov"; document.writeln("commercial domain: " + myObj['commercial']); // Outputs .com document.writeln("commercial domain: " + myObj.commercial); // Outputs .com </script> </pre> </body> </html>
  Preview Arrow