Skip to content

Commit 3e68c99

Browse files
committed
config scope
1 parent 3bf523f commit 3e68c99

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

js_basics/scope.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Global Scope:
2+
3+
// Variables declared outside of any function have global scope.
4+
5+
// They can be accessed from anywhere in the code, including inside functions.
6+
// const a = 45;
7+
// if(true){
8+
// console.log(a);
9+
// }
10+
11+
// Local Scope:
12+
13+
// Variables declared inside a function have local scope.
14+
15+
// They can only be accessed within the function where they are declared.
16+
17+
// if(true){
18+
// const b = 59;
19+
// }
20+
21+
// console.log(b); //it give u the error b is not defined

0 commit comments

Comments
 (0)