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.


<script>
   JavaScript
</script>

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".

#example

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


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: 

10
10.2
"Your Name"
"My dearm"

Variable:

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

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