8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a951d06 commit 814fec6Copy full SHA for 814fec6
32_variable_lookup.js
@@ -0,0 +1,25 @@
1
+// Lookup variable
2
+// js always lookup variable
3
+
4
+const numGlobal = 100;
5
6
+function total(num1, num2) {
7
+ //120 cz use numGlobal 100, but if inside function
8
+ //has nameGlobal with 50 result be 70
9
+ const numGlobal = 50;
10
+ const result = num1 + num2 + numGlobal;
11
+ //inner function
12
+ function multiply() {
13
+ //if result * numGlobal use value in function total
14
+ // sum be 3500, same with total function
15
+ // if multiply has local nameGlobal 1000 sum be 70000
16
+ const numGlobal = 1000;
17
+ const sum = result * numGlobal;
18
+ console.log(sum); //70000
19
+ }
20
+ multiply();
21
+ return result;
22
+}
23
24
+const result = total(10, 10);
25
+console.log(result);
0 commit comments