Skip to content

Commit b0924d0

Browse files
authored
Add files via upload
add note
1 parent 5367765 commit b0924d0

5 files changed

+95
-0
lines changed

Block scope in javascript.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Block Scope</title>
7+
</head>
8+
<body>
9+
<script>
10+
if(true){
11+
var a = 50;
12+
document.write(a);
13+
}
14+
document.write(a);
15+
</script>
16+
17+
</body>
18+
</html>

Default Parameter in javascript.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Default Parameter </title>
7+
</head>
8+
<body>
9+
<script>
10+
function add(a,b,c=10){
11+
document.write("A="+a+"<br>");
12+
document.write("B="+b+"<br>");
13+
document.write("C="+c+"<br>");
14+
15+
}
16+
add(100,50);
17+
</script>
18+
</body>
19+
</html>

Rest Parameters in javascript.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Rest Parameters</title>
7+
</head>
8+
<body>
9+
<script>
10+
// Rest parameters
11+
// the rest parameters allows to represent an indefinite number of arguments as an array.
12+
function rest(...args){
13+
document.write(args);
14+
15+
}
16+
rest(100);
17+
</script>
18+
19+
</body>
20+
</html>

Return function in javascript.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Return</title>
7+
</head>
8+
<body>
9+
<script>
10+
function add(a,b){
11+
return (a+b);
12+
}
13+
var x = add(10,20);
14+
document.write(x);
15+
</script>
16+
17+
</body>
18+
</html>

Variable Scope in javascript.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Variable Scope</title>
7+
</head>
8+
<body>
9+
<script>
10+
// javascript has two scope
11+
// 1. Gloabal 2. Local
12+
function sum(b){
13+
a = 20;// gloabal Variable
14+
var c = 30; // local variable
15+
return (a+b-c);
16+
}
17+
document.write(sum(20));
18+
</script>
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)