MainMenu

Home Java Overview Maven Tutorials

Javascript Overview for beginner


It is not mandatory but it is good to have knowledge of basics of HTML & java script for QA engineer

Javascript Overview


What is Javascript?


Javascript is a light weight, interpreted and easy to use programming laguage that can be embedded in the header of your web pages.
Javascript adds interactivity to a webpage.
Javascript work together with HTML and CSS to create attractive and interactive websites.
Javascript main funtion is Behaviour and interacivity.
Website script run either client side or server side. Ruby on rails, PHP, ASP.net are among the most popular server side languages and Javascript is a Client Side Scripting language
it runs on your computer after you have loaded the web page containing the script.
In Adobe applications or Node.js server side applications javascript used in general purpose and server-side application.
Javascript live in the HTML file mainly in Head tag
Before starting with Javascript, it is recommended that you gain basic knowledge of HTML and CSS.
Here are few examples of what java script can de :
display information based on the time of day
detect the visitor's browser
validate forms data
create cookies
change page content dynamically
Note: Java script run in the web browser.

Difference between Java and Javascript


1). Javascript is an OOP scripting language while java is an OOP programming language.
2). Java is a statically typed language while java is dynamic.
3). java code needs to be compiled while javascript code are all in text.
4). Application created in java run in virtual machine or browser while javascript code is run on a browser only.
5). Java mainly uses block based scoping i.e. a variable goes out of scope as soon as control comes out of the block while javascript mainly uses functiona based scoping.
6). Java has concept of constructors, which has some special properties and ensure that super class constructor run before the sub class while Javascript constructors are just function.
7). Havascript don't have NullPointerException java script variable can accept different kinds of data becuse of javascript is dynamically typesd language.

Syntax of Javascript


<html>
<head> <script type = "text/javascript">
........................................................ </script>
</head>
<body>
</body>
</html>
Javascript example of onclick event :
Example : In this example we will call the javascript function from the button on which onclick event persist.
<html>
<head>
<script type = "text/javascript">
function func()
{
var age = prompt("enter your age");
if(age>18)
{
document.write("you are adult and your age is " +age);
}
else
{
document.write("You are not adult");
}
}
</script>
</head>
<body>
<input type = "button" value = "Submit" onclick = "func()">
</body>
</html>
 


Tags :What is java script?,difference between Java & java script







No comments:

Post a Comment