WEB TECHNOLOGIES
CLIENT-SIDE PROCESSING AND
SCRIPTING
JAVASCRIPT
INTRODUCTION:
JavaScript (JS) is a light-weight object-oriented programming language which is used by
several websites for scripting the webpages. It is an interpreted, full-fledged programming
language that enables dynamic interactivity on websites when applied to an HTML
document.
JavaScript is used to create client-side dynamic pages. JavaScript is an object-based
scripting language which is lightweight and cross-platform.
JavaScript is not a compiled language, but it is a translated language. The JavaScript
Translator (embedded in the browser) is responsible for translating the JavaScript code for
the web browser.
JAVASCRIPT SYNTAX
JAVASCRIPT SYNTAX:
<script>
document.write("Hello JavaScript by JavaScript");
</script>
Client-Side JavaScript:
 Client-side JavaScript is the most common form of the language. The script should be
included in or referenced by an HTML document for the code to be interpreted by the
browser.
 It means that a web page need not be a static HTML, but can include programs that
interact with the user, control the browser, and dynamically create HTML content.
JAVASCRIPT VARIABLES
JavaScript Variable Scope:
The scope of a variable is the region of your program in which it is defined. JavaScript
variables have only two scopes.
• Global Variables − A global variable has global scope which means it can
be defined anywhere in your JavaScript code.
• Local Variables − A local variable will be visible only within a function where it is
defined. Function parameters are always local to that function.
JAVASCRIPT
JAVASCRIPT DATA TYPES:
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 DATATYPES
Primitive Data Types:
The primitive data types are the lowest level of the data value in JavaScript. Thefollowings
are primitive data types in JavaScript:
JAVASCRIPT DATATYPES
NON-PRIMITIVE DATA TYPES:
JAVASCRIPT DATATYPES
Examples
// Numbers:
let length = 16; let weight = 7.5;
// Strings:
let color = "Yellow";
let lastName = "Johnson";
// Booleanslet x = true; let y = false;
// Object:
const person = {firstName:"John", lastName:"Doe"};
// Array object:
const cars = ["Saab", "Volvo", "BMW"];
// Date object:
const date = new Date("2022-03-25");
JAVASCRIPT STATEMENT
JAVASCRIPT STATEMENTS
JavaScript statements are composed of: Values, Operators, Expressions, Keywords,and
Comments.
Semicolons: Semicolons separate Javascript statements.
let a, b, c;a = 2;
b = 3;
c = a + b;
console.log("The value of c is " + c + ".");
Code Blocks: JavaScript statements can be grouped together inside curly brackets. Such
groups are known as code blocks. The purpose of grouping is to define statements to be
executed together.
function myFunction() { console.log("Hello");
console.log("How are you?");
}
myFunction( )
JAVASCRIPT STATEMENT
White Space:
Javascript ignores multiple white spaces.
console.log(10 * 2);
console.log(10 * 2);
Line Length and Line Breaks:
Javascript code’s preferred line length by most programmers is up to 80 characters. The best
place to break a code line in Javascript, if it doesn’t fit, is after an operator.
Example: document.getElementById(“gift1").innerHTML =
"Hellogift!";
WT JAVASCRIPT

WT JAVASCRIPT

  • 1.
  • 2.
  • 3.
    JAVASCRIPT INTRODUCTION: JavaScript (JS) isa light-weight object-oriented programming language which is used by several websites for scripting the webpages. It is an interpreted, full-fledged programming language that enables dynamic interactivity on websites when applied to an HTML document. JavaScript is used to create client-side dynamic pages. JavaScript is an object-based scripting language which is lightweight and cross-platform. JavaScript is not a compiled language, but it is a translated language. The JavaScript Translator (embedded in the browser) is responsible for translating the JavaScript code for the web browser.
  • 4.
    JAVASCRIPT SYNTAX JAVASCRIPT SYNTAX: <script> document.write("HelloJavaScript by JavaScript"); </script> Client-Side JavaScript:  Client-side JavaScript is the most common form of the language. The script should be included in or referenced by an HTML document for the code to be interpreted by the browser.  It means that a web page need not be a static HTML, but can include programs that interact with the user, control the browser, and dynamically create HTML content.
  • 5.
    JAVASCRIPT VARIABLES JavaScript VariableScope: The scope of a variable is the region of your program in which it is defined. JavaScript variables have only two scopes. • Global Variables − A global variable has global scope which means it can be defined anywhere in your JavaScript code. • Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.
  • 6.
    JAVASCRIPT JAVASCRIPT DATA TYPES: JavaScriptprovides 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
  • 7.
    JAVASCRIPT DATATYPES Primitive DataTypes: The primitive data types are the lowest level of the data value in JavaScript. Thefollowings are primitive data types in JavaScript:
  • 8.
  • 9.
    JAVASCRIPT DATATYPES Examples // Numbers: letlength = 16; let weight = 7.5; // Strings: let color = "Yellow"; let lastName = "Johnson"; // Booleanslet x = true; let y = false; // Object: const person = {firstName:"John", lastName:"Doe"}; // Array object: const cars = ["Saab", "Volvo", "BMW"]; // Date object: const date = new Date("2022-03-25");
  • 10.
    JAVASCRIPT STATEMENT JAVASCRIPT STATEMENTS JavaScriptstatements are composed of: Values, Operators, Expressions, Keywords,and Comments. Semicolons: Semicolons separate Javascript statements. let a, b, c;a = 2; b = 3; c = a + b; console.log("The value of c is " + c + "."); Code Blocks: JavaScript statements can be grouped together inside curly brackets. Such groups are known as code blocks. The purpose of grouping is to define statements to be executed together. function myFunction() { console.log("Hello"); console.log("How are you?"); } myFunction( )
  • 11.
    JAVASCRIPT STATEMENT White Space: Javascriptignores multiple white spaces. console.log(10 * 2); console.log(10 * 2); Line Length and Line Breaks: Javascript code’s preferred line length by most programmers is up to 80 characters. The best place to break a code line in Javascript, if it doesn’t fit, is after an operator. Example: document.getElementById(“gift1").innerHTML = "Hellogift!";