JavaScript syntax is the set of commands, see the following example of how JavaScript programs are built:

var x, y, z;       // Declare Variables
x = 50; y = 60;      // Assign Values
z = x + y;         // Compute Values
document.write(z);  //show the message on screen

  • var = any data type you can store anything in this data type
  • x & y = x and y is variable name
  • 50 & 60 = is the value of variable
  • z = is also a variable that contains the value of x and y
  • document.write(z); = show the message on screen

I hope you will learn javascript syntax thanks !!!


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 code
</script>

The tag marker captures two important attributes -

  • Language - This adjective describes which writing language you use. Generally, its value will be JavaScript. Although recent types of HTML (and XHTML, followed) have eliminated the use of this attribute.
  • Type - This feature is now recommended to indicate the working language and its value should be set to "text / javascript".

So your JavaScript component will look -

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

Hello, world!

<html>
   <body>   
      <script language = "javascript" type = "text/javascript">
            document.write("Hello World!")
      </script>      
   </body>
</html>