What Is JavaScript Used For?

By Alexis Kindig

JavaScript is a scripting language used to create dynamic and interactive web content. It has a wide range of applications, including e-commerce (online shopping) and advertising networks such as Google AdSense.

Cookies

Perhaps the most common use of JavaScript is to set and read cookies, small files that contain data related to your use of a site in some way. They may be used to track things such as the last time you visited a website, which advertisements you saw or and items left in your shopping cart.

Advertising

JavaScript plays a prominent role in displaying advertisements on websites. It controls which ads are displayed and may set a cookie on your computer indicating you have seen the advertisement. JavaScript is also used to open windows for pop-up advertisements. Unless your browser restricts it, it may set the size and attributes of the opened window, too.

E-commerce

JavaScript is used extensively on many e-commerce sites. It plays a part in such tasks as adding items to your shopping cart, processing forms and submitting orders to be shipped. It can also be used to display dynamic content to users while shopping, such as related items and the cost of shipping.

Alerts

JavaScript is also used to display simple alerts to users. For instance, if you fill out a form and type in an invalid address or phone number, an alert will appear informing you of the mistake when you click the "Submit" button.

Security

JavaScript is used for security. Some login systems require you to type your password using a virtual, on-screen keyboard that uses JavaScript to accept your input.