JavaScript Introduction

JavaScript is a client side scripting language. Javascript code is downloaded from server and executed on clients browser.

We can include javascript statements in html file or we can create a javascript file and can import it on html files.

In html file we can use script tag to write javascript statements.

Syntax

we can write script tag inside head or inside body section.

Example

Result

We can also put script tag inside body generally we include as last statement of body

Result

Here document refers to body of browser and write() is a function used to write the content on browser body.

We can create a separate javascript file and can include that file in html
We have a javascript file names myJavaScript.js

Same folder having file first.html

Here we are including an external javascript file in html file the src attribute must contain path of javascript file.