When They "feel" the Same - Code - Part 3

What’s the Difference Between Scope and Context in JavaScript? When Scope and Context "feel" like the same thing (but they are not)
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
€96.96
List Price:  €135.76
You save:  €38.79
£80.48
List Price:  £112.68
You save:  £32.19
CA$144.46
List Price:  CA$202.25
You save:  CA$57.79
A$161.30
List Price:  A$225.82
You save:  A$64.52
S$136.99
List Price:  S$191.80
You save:  S$54.80
HK$777.77
List Price:  HK$1,088.91
You save:  HK$311.14
CHF 90.85
List Price:  CHF 127.20
You save:  CHF 36.34
NOK kr1,136.41
List Price:  NOK kr1,591.02
You save:  NOK kr454.61
DKK kr723.41
List Price:  DKK kr1,012.81
You save:  DKK kr289.39
NZ$179.27
List Price:  NZ$250.99
You save:  NZ$71.71
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,128.31
List Price:  ৳16,980.12
You save:  ৳4,851.81
₹8,576.54
List Price:  ₹12,007.50
You save:  ₹3,430.96
RM449.95
List Price:  RM629.95
You save:  RM180
₦154,533.88
List Price:  ₦216,353.62
You save:  ₦61,819.73
₨27,801.31
List Price:  ₨38,922.95
You save:  ₨11,121.63
฿3,449.55
List Price:  ฿4,829.51
You save:  ฿1,379.96
₺3,537.66
List Price:  ₺4,952.87
You save:  ₺1,415.20
B$618.15
List Price:  B$865.44
You save:  B$247.28
R1,871.01
List Price:  R2,619.49
You save:  R748.48
Лв189.93
List Price:  Лв265.91
You save:  Лв75.98
₩146,672.33
List Price:  ₩205,347.13
You save:  ₩58,674.80
₪365.15
List Price:  ₪511.23
You save:  ₪146.07
₱5,820.16
List Price:  ₱8,148.46
You save:  ₱2,328.30
¥15,717.92
List Price:  ¥22,005.72
You save:  ¥6,287.80
MX$2,062.93
List Price:  MX$2,888.18
You save:  MX$825.25
QR363.91
List Price:  QR509.49
You save:  QR145.58
P1,387.42
List Price:  P1,942.44
You save:  P555.02
KSh12,902.87
List Price:  KSh18,064.53
You save:  KSh5,161.66
E£5,074.19
List Price:  E£7,104.07
You save:  E£2,029.88
ብር12,747.15
List Price:  ብር17,846.53
You save:  ብር5,099.37
Kz91,190.88
List Price:  Kz127,670.88
You save:  Kz36,480
CLP$100,306.99
List Price:  CLP$140,433.80
You save:  CLP$40,126.81
CN¥731.98
List Price:  CN¥1,024.81
You save:  CN¥292.82
RD$6,097.60
List Price:  RD$8,536.88
You save:  RD$2,439.28
DA13,576.62
List Price:  DA19,007.81
You save:  DA5,431.19
FJ$232.59
List Price:  FJ$325.64
You save:  FJ$93.04
Q770.19
List Price:  Q1,078.30
You save:  Q308.10
GY$20,875.31
List Price:  GY$29,226.27
You save:  GY$8,350.96
ISK kr13,930.45
List Price:  ISK kr19,503.19
You save:  ISK kr5,572.73
DH1,006.87
List Price:  DH1,409.67
You save:  DH402.79
L1,858.26
List Price:  L2,601.64
You save:  L743.38
ден5,964.46
List Price:  ден8,350.49
You save:  ден2,386.02
MOP$799.84
List Price:  MOP$1,119.81
You save:  MOP$319.96
N$1,873.51
List Price:  N$2,622.99
You save:  N$749.48
C$3,673.10
List Price:  C$5,142.49
You save:  C$1,469.38
रु13,705.64
List Price:  रु19,188.44
You save:  रु5,482.80
S/374.69
List Price:  S/524.59
You save:  S/149.89
K399.88
List Price:  K559.85
You save:  K159.96
SAR375.52
List Price:  SAR525.74
You save:  SAR150.22
ZK2,780.17
List Price:  ZK3,892.35
You save:  ZK1,112.18
L482.45
List Price:  L675.45
You save:  L193
Kč2,440.45
List Price:  Kč3,416.73
You save:  Kč976.28
Ft40,319.96
List Price:  Ft56,449.56
You save:  Ft16,129.60
SEK kr1,111.16
List Price:  SEK kr1,555.68
You save:  SEK kr444.51
ARS$103,239.67
List Price:  ARS$144,539.67
You save:  ARS$41,300
Bs689.83
List Price:  Bs965.79
You save:  Bs275.96
COP$436,758.87
List Price:  COP$611,479.89
You save:  COP$174,721.02
₡50,884.43
List Price:  ₡71,240.24
You save:  ₡20,355.80
L2,537.04
List Price:  L3,551.96
You save:  L1,014.92
₲781,454.93
List Price:  ₲1,094,068.17
You save:  ₲312,613.23
$U4,391.87
List Price:  $U6,148.80
You save:  $U1,756.92
zł414.23
List Price:  zł579.94
You save:  zł165.71
Already have an account? Log In

Transcript

Now take a look at example D, where it says what is this in strict mode. so in this situation, I'm doing something here on line 36 from saying use strict and that basically says to the JavaScript engine for the execution of this function, use strict mode. And the difference here is that while this function executes, we're going to be in strict mode. So the the thing to behavior you'll see is different in the console, copy this code, paste it in your console, and we get cannot read property speed of undefined. So speed of undefined, that means the object that we're trying to get a speed property from is undefined. So this dot speed, it's not that this speed is undefined is that this is undefined.

And the reason is, because when we're in strict mode and browser based JavaScript, when we're in strict mode, we can't access the window object using this From a global function, it's just a one of the characteristics of strict mode. So, I'm going to continue out of strict mode, but I just wanted to point out that it's important to know that when you're using strict mode, you cannot access the window object using this inside of a global 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.