JavaScript

JavaScript is a programming language that is commonly used for web development . It has actually been develope by Netscape on a means that is used to add dynamic and interactive elements in websites.

Although JavaScript is more influenced by Java , its syntax is very similar to C and is based on ECMAScript, a scripting language that has been developed by Sun Microsystems.

If seen, JavaScript is a client-side scripting language, which means that its source code is processed through the client’s web browser and not on the web server. Assuming JavaScript functions run when a webpage is fully loaded without communicating with the server.

For example, a JavaScript function first checks a web form before submitting it to know that all the required fields are complete.

JavaScript code produces an error message before actually transmitting any information to the server.

Like other server-side scripting languages, such as PHP  and ASP, JavaScript code can be inserted anywhere in HTML  from a webpage.

But the output of the Server-Side Code is only displayed in HTML, while the JavaScript code is completely visible in the source of the webpage. At the same time it can be referenced as a separate .JS file , which is viewed  in a browser.

Here below is an example of a basic JavaScript function to add two numbers together. In this the function is called with parameters 9 and 5. If this code is included in the HTML of a webpage, then it will display text “14” in an alert box.

<script>  function sum(a,b)  {  return a + b;  }  var total = sum (9.5);  alert(total);  </script>

JavaScript functions are called <script> within tags or when certain specific events occur.

Examples include onClick, onMouseDown, onMouseUp, onKeyDown, onKeyUp, onFocus, onBlur, onSubmit, and others.

While standard JavaScript is still used to perform basic client-side functions, many web developers now prefer to use JavaScript libraries such as jQuery to add more advanced dynamic elements to websites. In.

« Back to Wiki Index