Here is an example of code written with in the document :
document.write("Hello World!"); is written inside the
<script> tag within the same HTML document.
.js extension. Then
this external file can be connected to your documents like HTML.
The external file is connected to the HTML document by script tag with
src attribute. Example
<script src="URL"></script> .
Here is an example of code written in the external document :
<script> tag can be placed inside head or inside
body but it is recommended to place it inside body tag at the end of every other tang inside
The document in the code represent the HTML document it is connected to, it is itself an object.