Introduction to JavaScript


If you are familiar with HTML and CSS then next and best step is to learn JavaScript.

“JavaScript is used to add Dynamic features in a web application”

Example:
Let us take an example to built a car:

1) (Role of HTML) Firstly we need parts like : The engine, drive train, brakes, tires,steering . This is equivalent to adding webforms elements like button,radio-button,input fields etc using HTML. 

2) (Role of CSS) Secondly we need to arrange the set postion of these elements,like where tires will come and where brakes. And this is equivalent to setting postions,add colors,padding,margin settings using CSS. 

3) (Role of JavaScript) Now everything is arranged but now we want to start the engine by pressing “start“ button from car ,this part will be done with JavaScript i.e JavaScript will add funtionality.
JavaScript will connect the the “Start”(created using HTML and CSS) button of car with it’s engine.

  • What is JavaScript ?
JavaScript is a “scripting language" that give us programming language like functionality used to develop web applications.

JavaScript is a client-side scripting language, which means the code is processed and manipulated by the client's web browser not on the web server.

  •  JavaScript vs Java
JavaScript and Java both are different programming languages. The word “Java” in “JavaScript” has nothing  to do anything with Java programming language.The word “java” in front of “JavaScript” might be added to gain popularity.


  • Do we need to install JavaScript in browers or anywhere ?

No,We need to install JavaScript anywhere.


Example of usage of JavaScript:
1)To check textbox must not be empty.


2)To add button on Click.

3)To Enable/Disable text-box on click.


  • Embedding JavaScript in Webpage:

Basically there are three ways to embedding JavaScript in web application:
1) By Creating Separate JavaScript file then adding it to using "script" tags. (most recommended)
Example: <script src='login.js' type='text/javascript'></script>


2) By write code under <script></script> tags under <head></head> tags.
Example: 
<script>
 ////----javaScript Code here-----------------////
</script>

 3) Withing the element. (least recommended)
Example: <button onClick="alert('hello World ! ')">Click me !</button>
tank

0

Target :10