Java Script in web development - Taleem Dunya

Lecture 08

Java Script in web development

Java Script (JS) is a high-level, dynamic, and versatile programming language that is primarily used for adding interactivity and behavior to websites. It allows web developers to create dynamic and interactive features within web pages, such as animations, form validation, and updating content without requiring a full page reload. JavaScript is an essential component of web development alongside HTML (Hypertext Markup Language) and CSS (Cascading Style Sheets).

Client-Side Scripting: JavaScript is executed on the client side, which means it runs in the web browser of the user. This enables it to interact with the Document Object Model (DOM) of a web page and respond to user actions. 

Dynamic Typing: JavaScript is a dynamically typed language, meaning you don't need to declare the data type of a variable explicitly. The type of a variable can change during the program's execution. 

Event-Driven: JavaScript is heavily event-driven, meaning it can respond to events such as user clicks, form submissions, and more, and trigger actions in response to these events. 

Cross-Platform: JavaScript is supported by most modern web browsers, making it a cross-platform language. This means code written in JavaScript will work on various operating systems and browsers. 

Extensibility: JavaScript can be extended through the use of libraries and frameworks, such as jQuery, React, Angular, and Vue.js, which provide pre-written code for common tasks. 

Server-Side Development: While JavaScript is primarily used on the client side, it can also be used on the server side with technologies like Node.js. This allows developers to use JavaScript for both front-end and back-end development. JavaScript has evolved significantly over the years, and it is an integral part of modern web development. It's also used in various other contexts, such as mobile app development (using frameworks like React Native), desktop application development (using frameworks like Electron), and even in some server-side applications.

Application of JavaScript

JavaScript is used to create interactive websites. It is mainly used for: Client-side validation, Dynamic drop-down menus, Displaying date and time, Displaying pop-up windows and dialog boxes (like an alert dialog box, confirm dialog box and prompt dialog box), Displaying clocks


JavaScript Variable

A JavaScript variable is simply a name of storage location. There are two types of variables in JavaScript : local variable and global variable.

There are some rules while declaring a JavaScript variable (also known as identifiers).

1. Name must start with a letter (a to z or A to Z), underscore( _ ), or dollar( $ ) sign.

2. After first letter we can use digits (0 to 9), for example value1.

3. JavaScript variables are case sensitive, for example x and X are different variables.


Program in Java script

Write a program in Java Script to add two numbers


Data Types in Java script

JavaScript provides different data types to hold different types of values. There are two types of data types in JavaScript.

  1. Primitive data type
  2. Non-primitive (reference) data type


JavaScript is a dynamic type language, means you don't need to specify type of the variable because it is dynamically used by JavaScript engine. You need to use var here to specify the data type. It can hold any type of values such as numbers, strings etc.

Operators used in Java Script

JavaScript operators are symbols that are used to perform operations on operands. For example:


There are following types of operators in JavaScript. Arithmetic Operators Comparison (Relational) Operators Bitwise Operators Logical Operators Assignment Operators Special Operators