Global Scope - Demonstration

1 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€86.38
List Price:  €120.93
You save:  €34.55
£73.62
List Price:  £103.07
You save:  £29.45
CA$135.69
List Price:  CA$189.98
You save:  CA$54.28
A$153.44
List Price:  A$214.82
You save:  A$61.38
S$127.99
List Price:  S$179.20
You save:  S$51.20
HK$784.89
List Price:  HK$1,098.87
You save:  HK$313.98
CHF 81.04
List Price:  CHF 113.46
You save:  CHF 32.42
NOK kr990.15
List Price:  NOK kr1,386.25
You save:  NOK kr396.10
DKK kr644.23
List Price:  DKK kr901.95
You save:  DKK kr257.71
NZ$165.43
List Price:  NZ$231.62
You save:  NZ$66.18
د.إ367.20
List Price:  د.إ514.09
You save:  د.إ146.89
৳12,187.59
List Price:  ৳17,063.11
You save:  ৳4,875.52
₹8,605.29
List Price:  ₹12,047.75
You save:  ₹3,442.46
RM424
List Price:  RM593.62
You save:  RM169.62
₦154,479.55
List Price:  ₦216,277.55
You save:  ₦61,798
₨28,273.68
List Price:  ₨39,584.28
You save:  ₨11,310.60
฿3,246.72
List Price:  ฿4,545.54
You save:  ฿1,298.81
₺3,939.35
List Price:  ₺5,515.25
You save:  ₺1,575.90
B$558.29
List Price:  B$781.63
You save:  B$223.34
R1,778.13
List Price:  R2,489.45
You save:  R711.32
Лв168.86
List Price:  Лв236.41
You save:  Лв67.55
₩136,005.56
List Price:  ₩190,413.23
You save:  ₩54,407.66
₪354.06
List Price:  ₪495.71
You save:  ₪141.64
₱5,649.43
List Price:  ₱7,909.43
You save:  ₱2,260
¥14,403.40
List Price:  ¥20,165.34
You save:  ¥5,761.94
MX$1,890.44
List Price:  MX$2,646.69
You save:  MX$756.25
QR363.81
List Price:  QR509.35
You save:  QR145.54
P1,340.52
List Price:  P1,876.78
You save:  P536.26
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£5,027.49
List Price:  E£7,038.69
You save:  E£2,011.20
ብር13,454.82
List Price:  ብር18,837.30
You save:  ብር5,382.47
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$92,761.57
List Price:  CLP$129,869.91
You save:  CLP$37,108.33
CN¥717.91
List Price:  CN¥1,005.11
You save:  CN¥287.19
RD$5,890.40
List Price:  RD$8,246.80
You save:  RD$2,356.39
DA13,009.70
List Price:  DA18,214.10
You save:  DA5,204.40
FJ$224.25
List Price:  FJ$313.96
You save:  FJ$89.71
Q766.41
List Price:  Q1,073.01
You save:  Q306.59
GY$20,866.01
List Price:  GY$29,213.25
You save:  GY$8,347.23
ISK kr12,403.75
List Price:  ISK kr17,365.75
You save:  ISK kr4,962
DH911.88
List Price:  DH1,276.68
You save:  DH364.79
L1,709.82
List Price:  L2,393.82
You save:  L683.99
ден5,313.40
List Price:  ден7,438.97
You save:  ден2,125.57
MOP$806.30
List Price:  MOP$1,128.85
You save:  MOP$322.55
N$1,794.81
List Price:  N$2,512.80
You save:  N$717.99
C$3,670.34
List Price:  C$5,138.62
You save:  C$1,468.28
रु13,731.28
List Price:  रु19,224.34
You save:  रु5,493.06
S/359.98
List Price:  S/503.99
You save:  S/144
K416.61
List Price:  K583.28
You save:  K166.66
SAR375.18
List Price:  SAR525.27
You save:  SAR150.08
ZK2,410.99
List Price:  ZK3,375.48
You save:  ZK964.49
L434.39
List Price:  L608.17
You save:  L173.77
Kč2,142.08
List Price:  Kč2,999
You save:  Kč856.92
Ft34,674.46
List Price:  Ft48,545.63
You save:  Ft13,871.17
SEK kr946.60
List Price:  SEK kr1,325.27
You save:  SEK kr378.67
ARS$118,213.68
List Price:  ARS$165,503.89
You save:  ARS$47,290.20
Bs689.17
List Price:  Bs964.87
You save:  Bs275.69
COP$412,775.05
List Price:  COP$577,901.59
You save:  COP$165,126.53
₡50,269.99
List Price:  ₡70,380
You save:  ₡20,110
L2,602.96
List Price:  L3,644.25
You save:  L1,041.28
₲795,764
List Price:  ₲1,114,101.44
You save:  ₲318,337.43
$U4,088.51
List Price:  $U5,724.08
You save:  $U1,635.56
zł368.52
List Price:  zł515.94
You save:  zł147.42
Already have an account? Log In

Transcript

Opened the examples folder and then open the global scope sub folder. Now let's look at the exe example global scope one. Here I have a global variable called speed, I know that's global because it's not in a function is defined outside of a function. So I declare the the variable speed, which is equal to 25. And then I have a console log statement outputting, that variable, and we should get 25 in the console. So if I click show examples, and then global scope, example one, we can see we get global speed 25 not a big surprise.

So let's look at global scope number two. So once again, I have the global variable speed, which is equal 25. But then I have this function inside of the function. I also output in the console speed from foo, which is the global speed variable defined on line three. And then on line nine, I have the console log statement to output, the value the global variable and online 10 execute foo, which also outputs that global variable. So let's take Look at show examples global scope two.

And I see the two messages speed from global scope 25 speed one through 25. Pretty simple stuff. But the point here is that a global variable is one is defined in the global scope. And we know we're in in global scope if we're not in a function, because variable speed is not defined in a function, which means it's global, even though we access it in a function on line six. This speed variable right here is still referencing the global speed. And then we're outputting it here.

So just remember that a global variable is one that is defined outside of a function

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.