HTML

Introduction:

  • Java script is a client side scripting language.
  • it is used to create dynamic web page.
  • It is a case-sensitive language
  • It is an object based scripting language.
  • By using java script we can perform validations.
  • Java script always executes on client environment and it makes the execution process fast.
  • we can write java script code in html file or separate file.
  • java script file extension must be ".js".
  • It is used for displaying pop-up msgs like alert and confirm msgs.
  • java script is a light weight and interpreted programming language.
  • It is recommended to keep the script tags with in the html head tags. 
Syntax: we can write the java script code within the script tags.

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

Type:This attribute is what is now recommended to indicate the scripting language in use and its value should be set to "text/javascript".
Note:No need to use type attribute because script is the default scripting language in html.
EX:


Document.write method() is used to display the content.

OUTPUT:


EX-2: By using separate file for javascript

Html Code:

Note: In src attribute we are specifying the address (or) path of the .js file.

.Js Code:

Note: In js file we are not writing any script tags.

OUTPUT:


By Using Method:

Code:

OUTPUT:
After Loading:

After Clicking The Button:

Datatpes:
List of primitive data types are

  • Numbers(1,75)
  • Strings(deepika,john)
  • Boolean(true,false)
It supports null and undefined datatypes which can hold only one value.
In addition to this it also supports object datatype.

Variables:
A variable is nothing but a field which holds some value which can be changed.
Ex: var a=10;
       var name=john;
In javascript variables must be identified with unique names.