What is JavaScript?

JavaScript is a programming language for web designing. It is a lightweight, object-based scripting language. It is very easy to learn. It is used to add the dynamic components for a website. It is supported by most of the web browsers. It has made modern web applications possible. JavaScript is also has an ability to be run as an back end in any website development.
Before you go for Javascript you should be have hands on experience and good knowledge on HTML and CSS.
JavaScript also allows your page to be interactive. You can add animations into the page which either attract attention to a specific part of the page or which make the page easier to use.



History of JavaScript

Javascript was introduced in 1995 as a way to add programs to web pages in the Netscape Navigator browser. The language has since been adopted by all other major graphical web browsers.



Why JavaScript?

  • Client side validation of form elements instead of sending data to server every time.
  • To provide users notifications from the server.
  • To load data in the background from the server and loaded on to the page side without reloading.
  • JavaScript is fast and Reliable.
  • Open and cross-platform.


JavaScript Syntax

JavaScript codes can be written within <script>...</script> tags in a HTML document. <script>...</script> with javascript code can be placed anywhere in the HTML document but it is recommended to place it inside <head> tags.

Here is an example of JavaScript:

Example:

<html>
<head>
<script type="text/javascript">
function jsexample() {
alert("Hello this is a JavaScript example!")
}
</script>
</head>
<body>
<h1>JavaScript Example </h1>
<input type="button" onclick="jsexample()" value="Click Me!">
</body>
</html>

Run Example