what is javascript used for

What is JavaScript Used for?

The internet houses millions of web pages hosted by websites that serve different purposes. Some attract you while others don't. You like the ones which look good, are easy to use, and interactive enough to engage you for long. This is where Javascript comes into the scene. What is it used for? Let's find out.

<div style="..." onmouseover="color(this, 'red');" onmouseout="uncolor(this)">Red</div><div style="..." onmouseover="color(this, 'green');" onmouseout="uncolor(this)">Green</div><div style="..." onmouseover="color(this, 'blue');" onmouseout="uncolor(this)">Blue</div><script>  function color(el, color) {    el.style.color = '#FFFFFF';    el.style.backgroundColor = color;  }  function uncolor(el) {    el.style.color = '#000000';    el.style.backgroundColor = '#E6E6E6';  }</script>
Example 2 This is a perfect example of an event. We come across something similar on several web pages. On the event of clicking a button, a message is displayed. It may tell you what to do next or inform you of something useful. In the example below, a simple message is displayed on clicking the button.
Button
<div onclick="alert('Hey you just clicked a button!');">Button</div>
Although JavaScript is used extensively, the user shouldn't completely depend on it. It has certain security issues as anyone can duplicate the code. Different browsers interpret it differently according to their rendering engines, which may lead to inconsistencies in the display. However, despite concerns like these, Javascript is popular and widely used across the web.

Похожие статьи