Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 03afc36

Browse files
Updating JS_Function Module - 18th July 2023
1 parent 015cff3 commit 03afc36

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

‎Functions/JS_Hoisting.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Hoisting is a concept where a variable can be used before its declaration
2+
3+
console.log(test)
4+
var test
5+
6+
// Below is an example of variable hoisting - VAR can be hoisted, LET and CONST doesn't allow hoisting.
7+
a = 5
8+
console.log(a)
9+
var a
10+
11+
12+

‎Functions/JS_Recusion.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Program to count number to 1
2+
3+
function countNumber(num){
4+
console.log(num)
5+
num = num-1
6+
if(num>0){
7+
countNumber(num)
8+
}
9+
}
10+
11+
countNumber(10)

‎Functions/Scope_of_Variable.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// // program to show the change in global variable
2+
// let a = "hello";
3+
4+
// function greet() {
5+
// a = 3
6+
// b = 6
7+
// }
8+
9+
// // before the function call
10+
// console.log(a);
11+
// console.log(b);
12+
13+
// //after the function call
14+
// greet();
15+
// console.log(a); // 3
16+
17+
18+
// program showing local scope of a variable
19+
let a = "hello";
20+
21+
function greet() {
22+
let b = "World"
23+
console.log(a + b);
24+
}
25+
26+
greet();
27+
console.log(a + b); // error

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /