JavaScript can be applied using JavaScript statements embedded within the <script> ... </script> HTML tags on a web page.

You can place <script> tags, which contain your JavaScript, anywhere within your webpage, but it is usually recommended to keep it within <head> tags.

The <script> tag warns the browser system to begin interpreting all the text between these tags as text. A simple syntax for your JavaScript will appear like this.


Javascript Attributes

  • language - This attribute determines which language you use. Generally, its value will be JavaScript.
  • type - This attribute is now recommended to indicate the writing language used and its value should be set in "text / javascript".


<script language = "javascript" type = "text/javascript">
  //javascript code

Declare variables and assign values

var x, y, z;       // Declare Variables
x = 51; y = 16;    // Assign Values
z = x + y;         // Compute Values

JavaScript Type Of values

JavaScript syntax specifies two types of values:

  • Fixed values   - called Literals value
  • Variable values - called  Variables

Literals value: 

"Your Name"
"My dearm"


var name = "Rathorji";
var weight = 100+"KG";
var abc; 
abc = 2000

name, weight, and abc is called variables in the above example