Internet Based Programming: Frontend Web Development
Internet Based Programming: Frontend Web Development
05/10/2025 2
1
05/10/2025
05/10/2025 3
05/10/2025 4
2
05/10/2025
05/10/2025 5
05/10/2025 6
3
05/10/2025
05/10/2025 7
05/10/2025 8
4
05/10/2025
05/10/2025 9
<body> <body>
<script> <script>
var i = 5; let i = 5;
for (var i = 0; i < 10; i++) {} for (let i = 0; i < 10; i++) {}
document.write(i); document.write(i);
</script> </script>
</body> </body>
05/10/2025 10
5
05/10/2025
05/10/2025 11
05/10/2025 12
6
05/10/2025
05/10/2025 13
05/10/2025 14
7
05/10/2025
05/10/2025 15
variable: for every iteration the value of the next property is assigned to the
variable.
Iterable_data: an object that has iterable properties.
05/10/2025 16
8
05/10/2025
05/10/2025 17
05/10/2025 18
9
05/10/2025
05/10/2025 19
05/10/2025 20
10
05/10/2025
05/10/2025 21
05/10/2025 22
11
05/10/2025
05/10/2025 23
05/10/2025 24
12
05/10/2025
05/10/2025 25
05/10/2025 26
13
05/10/2025
<body>
<p id="demo"></p>
<script> This function known as arrow
const x = (a, b) => { return a * b };
document.getElementById("demo").innerHTML = x(4, 3); function
</script>
</body>
05/10/2025 27
05/10/2025 28
14
05/10/2025
05/10/2025 29
05/10/2025 30
15
05/10/2025
05/10/2025 31
05/10/2025 32
16
05/10/2025
05/10/2025 33
• A JavaScript function does not perform any checking on parameter values (arguments):
JavaScript function definitions do not specify data types for parameters.
JavaScript functions do not perform type checking on the passed arguments.
JavaScript functions do not check the number of arguments received.
If a function is called with missing arguments (less than declared), the missing values are set
to undefined. <body>
<p id="demo"></p>
<script>
function myFunction(x, y) {
if (y === undefined) {
y = 2;
}
return x * y;
}
document.getElementById("demo").innerHTML = myFunction(4);
</script>
</body>
05/10/2025 34
17
05/10/2025
<!DOCTYPE html>
<html>
<body>
<p>If y is not passed or undefined, then y = 10:</p>
<p id="demo"></p>
<script>
function myFunction(x, y = 10) {
return x + y;
}
document.getElementById("demo").innerHTML = myFunction(5);
</script>
</body>
</html>
05/10/2025 35
05/10/2025 36
18
05/10/2025
05/10/2025 37
05/10/2025 38
19
05/10/2025
<body>
<h2>Creating a JavaScript Object:</h2>
<p id="demo"></p>
<script>
const person = new Object();
person.firstName = "John";
person.lastName = "Doe";
person.age = 50;
person.eyeColor = "blue";
document.getElementById("demo").innerHTML =
person.firstName + " is " + person.age + " years old.";
</script>
</body>
05/10/2025 39
<body>
<h2>JavaScript Object Properties</h2>
<p id="demo1"></p>
<p id="demo2"></p>
<script>
const person = {
firstname: "John",
lastname: "Doe",
age: 50,
eyecolor: "blue"
};
document.getElementById("demo1").innerHTML = person.firstname + " is " + person.age + " years old.";
document.getElementById("demo2").innerHTML = person["firstname"] + " is " + person["age"] + " years old.";
</script>
</body>
05/10/2025 40
20
05/10/2025
05/10/2025 41
<body>
<p id="demo"></p>
<script>
const person = { fname: "John", lname: "Doe", age: 25};
person.fname = "Mike";
document.getElementById("demo").innerHTML = person.fname;
</script>
</body>
05/10/2025 42
21
05/10/2025
<body>
<p id="demo"></p>
<script>
const person = { lname: "Doe", age: 25};
person.fname = "John";
document.getElementById("demo").innerHTML = person.fname;
</script>
</body>
05/10/2025 43
<body>
<h2>JavaScript Object Methods</h2>
<p id="demo"></p>
<script>
const person = {
firstName: "John",
lastName: "Doe", In JavaScript,
id: 5566, the this keyword refers
fullName: function () {
return this.firstName + " " + this.lastName;
to an object. If it is
} used in an object
}; method, this refers to
document.getElementById("demo").innerHTML = person.fullName(); the object.
</script>
</body>
05/10/2025 44
22
05/10/2025
document.getElementById("demo").innerHTML = myObj.cars["car2"]; or
document.getElementById("demo").innerHTML = myObj["cars"]["car2"];
05/10/2025 45
05/10/2025 46
23
05/10/2025
05/10/2025 47
05/10/2025 48
24
05/10/2025
05/10/2025 49
05/10/2025 50
25