The object stores its identity and state in fields( also called variables) and exposes its behavior through functions (actions).
Need for Scripting
Consider an organization that provides a web site that allows its customers to view their products. The company has received frequent customer feedback to provide the shopping facility online. Therefore, the company has decided to add the shopping facility in their web site by creating dynamic web pages. Here the main task of the developer is to validate the customer’s inputs while they shop online. For example, details such as credit card number, email , and phone number entered by the customer must be in a proper format. Further, the developer also needs to retrieve the chosen products and their quantity to calculate the total cost.
The developer can handle all these critical tasks by using a scripting language. A scripting language refers to a set of instructions that provides some functionality when the user interacts with a web page.
Scripting refers to a series of commands that are interpreted and executed sequentially and immediately on an occurrence of an event. This event is an action generated by a user while interacting with a web page. Examples of events include button clicks, selecting with a product from the menu, and so on. Scripting languages are often embedded in the HTML pages to change the behaviour of the web pages according to the user’s requirements.
There are two types of scripting languages. They are:
1) Client-side Scripting: Refers to a script being executed on the client’s machine by the browser.
2) Server-side Scripting: Refers to a script being executed on a web server to generate dynamic HTML pages.
Note: In earlier days, script languages were called batch languages or job control languages.
Quickly responding to user’s requests.
Generating HTML pages by writing HTML content
Validating the data entered by the user
Performing simple calculations on the client-sides
There are two main purposes of the <script> tag, which are: