Editor Arrow Download Open
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript global scope</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> // variable var greetings = "Good morning, have a nice day!"; //function function fun1() { document.writeln("Hello world!" + '<br />'); } // object var myObj = { "commercial": ".com", "network": ".net" }; function myfun(){ // variable access document.writeln(greetings + '<br />'); // function access fun1(); // object property access document.writeln(myObj.commercial + '<br />'); } myfun(); document.writeln(greetings + '<br />'); fun1(); document.writeln(myObj.commercial + '<br />'); </script> </pre> </body> </html>
  Preview Arrow