Week 5 All Topics Slides
Week 5 All Topics Slides
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
• Early JavaScript had only a few common uses
• 2000s onward saw more sophisticated uses for JavaScript
• AJAX as both an acronym and a general term
JavaScript in Contemporary
Software Development
Web System and Tecnologies CS 521
Writing and Storing the Script
Inline JavaScript
• Web crawler
• Browser plug-in
• Text-based client
• Visually disabled client
• The <NoScript> Tag
Introduction to JavaScript repeat
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
repeat
• Early JavaScript had only a few common uses
• 2000s onward saw more sophisticated uses for JavaScript
• AJAX as both an acronym and a general term
JavaScript in Contemporary
Software Development
Variables and Data Types
Variables
• Types of Loops
• For Loop
Loops
• ForEach Loop
Functions (1)
Functions
Function Declarations vs. Function
Expressions
• Functions are the building block for
modular code in JavaScript
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
// defines a function using a function expression
var sub = function subtotal(price,quantity) {
return price * quantity;
};
// invokes the function
var result = sub(10,2);
It is conventional to leave out the function name
in function expressions
Functions
• Anonymous Function Expressions
// defines a function using an anonymous function expression
var calculateSubtotal = function (price,quantity) {
return price * quantity;
};
// invokes the function
var result = calculateSubtotal(10,2);
Functions
Arrow Functions
//normal function
function square(n) {
return n*n;
}
//arrow function
sq = (n) => n*n
//Another example
sum = (n,m) => n+m