Topic 37-45
Topic 37-45
Introduction to JavaScript
Client Side Scripting
Introduction to JavaScript
JavaScript History
• JavaScript was introduced by Netscape in their Navigator browser
back in 1996
• JavaScript that is supported by your browser contains language
features
• not included in the current ECMAScript specification and
• missing certain language features from that specification
• Commonly used version of ECMAScript is the Sixth Edition (ES6)
• 12th Edition (ECMAScript 2021 ) released in 2021
JavaScript and Web 2.0
• Web crawler
• Browser plug-in
• Text-based client
• Visually disabled client
• The <NoScript> Tag
Introduction to JavaScript
JavaScript History
• JavaScript was introduced by Netscape in their Navigator browser
back in 1996
• JavaScript that is supported by your browser contains language
features
• not included in the current ECMAScript specification and
• missing certain language features from that specification
• Commonly used version of ECMAScript is the Sixth Edition (ES6)
• 12th Edition (ECMAScript 2021 ) released in 2021
JavaScript and Web 2.0
Types of Loops
var count = 0;
while (count < 10) {
// do something
// ...
count++;
}
count = 0;
do {
// do something
// ...
count++;
} while (count < 10);
Loops
For Loop
Loops
ForEach Loop
var objName = {
name1: value1,
name2: value2,
// ...
nameN: valueN
};
Objects
Functions (1)
Functions
Function Declarations vs. Function Expressions
function subtotal(price,quantity) {
return price * quantity;
}
• The above is formally called a function
declaration, called or invoked by using the
() operator
var result = subtotal(10,2);
Functions
Function Declarations vs. Function Expressions
//normal function
function square(n) {
return n*n;
}
//arrow function
sq = (n) => n*n
//Another example
sum = (n,m) => n+m