- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path32_variable_lookup.js
More file actions
Latest commit
25 lines (22 loc) · 646 Bytes
/
Copy path32_variable_lookup.js
File metadata and controls
25 lines (22 loc) · 646 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
// Lookup variable
// js always lookup variable
constnumGlobal=100;
functiontotal(num1,num2){
//120 cz use numGlobal 100, but if inside function
//has nameGlobal with 50 result be 70
constnumGlobal=50;
constresult=num1+num2+numGlobal;
//inner function
functionmultiply(){
//if result * numGlobal use value in function total
// sum be 3500, same with total function
// if multiply has local nameGlobal 1000 sum be 70000
constnumGlobal=1000;
constsum=result*numGlobal;
console.log(sum);//70000
}
multiply();
returnresult;
}
constresult=total(10,10);
console.log(result);