To embed a JavaScript into a webpage, we use the Script tag of HTML with the Type attribute set to text/lavaScript. The first script we will include is the document.write method for dynamically outputting HTML on the page. Statements in JavaScript ends with a semicolon, but a new line also functions as the end of a statement, meaning that we don't have to use semi colons unless we have several statements on the same line.
As for comments, JavaScript uses standard C++ notation with both single line and multi line comments. Wide space is also ignored, so we can add extra spaces to make the scripts more readable. As we can see in the browser, the script inside the body section is executed immediately when the page loads to display the text. What we can see is that it's executed on the client's side. This means that there is less load on the server compared to server side scripts. However, it also means that it is up to the client whether the script is executed or not.
The client may have disabled JavaScript or use an old browser that does not support it. If the browser does not support JavaScript it's displayed as normal HTML. To prevent this we can surround the script with a HTML comment tag. There is also the No script HTML tag to present an alternative message that can only be seen by browsers who does not support script. However, JavaScript is the most popular scripting language and it works with all major browsers today. Another way to include JavaScript is by saving the script in a file with a js file extension. We can then embed the external script by pointing to that file in the Source attributes of the Script tag. This way several pages can use the same script without having to type it on every page.