0 FCD 772 B 1711877821587
0 FCD 772 B 1711877821587
WEB
TECHNOLOGIES
• Using var
• Using let
• Using const
• Using nothing
What are Variables?
• Example
• var x = 5;
• var y = 6;
• var z = x + y;
Variables
• Example
• let x = 5;
• let y = 6;
• let z = x + y;
Variables
• Example
• x = 5;
• y = 6;
• z = x + y;
When to Use JavaScript var?
If you want your code to run in older browser, you must use
var.
When to Use JavaScript var?
If you want your code to run in older browser, you must use
var.
When to Use JavaScript var?
If you want your code to run in older browser, you must use
var.
When to Use JavaScript var?
If you want your code to run in older browser, you must use
var.
JavaScript Identifiers
• Names can also begin with $ and _ (but we will not use it in this
tutorial)
•x=x+5
JavaScript Data Types
• JavaScript variables can hold numbers like 100 and text values
like "John Doe".
• JavaScript can handle many types of data, but for now, just
think of numbers and strings.
• Example
}
JavaScript Function Syntax
// code to be executed
• Example
• function myFunction(a, b) {
• }
Why Functions?
• You can reuse code: Define the code once, and use it many
times.
• You can use the same code many times with different
arguments, to produce different results.
JavaScript Events
• An HTML event can be something the browser does, or something a user does.