JavaScript - Basic Structure

Basic Structure

It starts with the opening <script> tag; then inside the it, follows the attributes:

  • src - sets the address/location of the external script file. For example: src="filename.js (for external method only)
  • type - sets the type of file and language. type="text/javascript"

Then followed by the javascript code and lastly the closing </script> tag

While using the inline method, javascript can be written inside the HTML opening tag element, which does not require you to write the <script> tags.

note
NOTE:

Then .js extension name is used when saving an external file for javascript.


ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT