-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18_scopes.js
More file actions
47 lines (31 loc) · 843 Bytes
/
Copy path18_scopes.js
File metadata and controls
47 lines (31 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Hoisting
function one() {
const username = "chetan"
function two() {
const website = "youtube"
console.log(username);
}
// console.log(website) error --> website is not defined
two()
}
one()
if (true) {
const username = "chetan"
if (username === "chetan") {
const websiteone = " youtube"
console.log(username + websiteone);
}
// console.log(websiteone); error --> websiteone is not defined
}
// console.log(username); error --> username is not defined
// Interesting Concept
console.log(addone(5));
function addone(num) {
return num + 1
}
console.log(addone(5));
// addTwo(5) error --> Cannot access 'addTwo' before initialization
const addTwo = function(num) {
return num + 2
}
console.log(addTwo(5));