1<!--
2 Method 1: external script
3 - Should be placed in the <head> section of your HTML
4 - The 'src' should contain the path to a local file or external URL
5 - The 'defer' attribute will make it execute after the DOM is loaded
6-->
7<script src="script.js" type="text/javascript"></script>
8<script src="script.js" type="text/javascript" defer></script>
9
10<!--
11 Method 2: inline code
12 - Should be placed in the <head> or <body> section of your HTML
13 - Place it before the </body> to make it execute after the DOM is loaded
14-->
15<script> alert("Hello world!"); </script>
1console.log("Hello, World!");
2
3console.error("Error, World!"); // For errors
4
5console.warn("Warning, World!"); // For warnings
6
7console.clear(); // To clear the console
1<script type="text/javascript">
2 alert("This alert box was called with the onload event");
3</script>
1<script src="file1.js" type="text/javascript"></script>
2<script src="file2.js" type="text/javascript"></script>
3