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
€86.15
List Price:  €120.62
You save:  €34.46
£75.19
List Price:  £105.27
You save:  £30.08
CA$136.98
List Price:  CA$191.79
You save:  CA$54.80
A$142.01
List Price:  A$198.83
You save:  A$56.81
S$127.77
List Price:  S$178.89
You save:  S$51.11
HK$780.78
List Price:  HK$1,093.13
You save:  HK$312.34
CHF 78.58
List Price:  CHF 110.01
You save:  CHF 31.43
NOK kr966.97
List Price:  NOK kr1,353.80
You save:  NOK kr386.82
DKK kr643.64
List Price:  DKK kr901.12
You save:  DKK kr257.48
NZ$169.78
List Price:  NZ$237.69
You save:  NZ$67.91
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,257.82
List Price:  ৳17,161.44
You save:  ৳4,903.61
₹9,207.49
List Price:  ₹12,890.86
You save:  ₹3,683.36
RM394.56
List Price:  RM552.40
You save:  RM157.84
₦137,150.28
List Price:  ₦192,015.88
You save:  ₦54,865.60
₨28,030.81
List Price:  ₨39,244.26
You save:  ₨11,213.44
฿3,169.53
List Price:  ฿4,437.47
You save:  ฿1,267.94
₺4,397.52
List Price:  ₺6,156.70
You save:  ₺1,759.18
B$518.59
List Price:  B$726.05
You save:  B$207.46
R1,630.35
List Price:  R2,282.55
You save:  R652.20
Лв168.51
List Price:  Лв235.93
You save:  Лв67.41
₩147,756.71
List Price:  ₩206,865.31
You save:  ₩59,108.59
₪310.18
List Price:  ₪434.26
You save:  ₪124.08
₱5,853.29
List Price:  ₱8,194.84
You save:  ₱2,341.55
¥15,765.70
List Price:  ¥22,072.61
You save:  ¥6,306.91
MX$1,747.93
List Price:  MX$2,447.18
You save:  MX$699.24
QR366.86
List Price:  QR513.62
You save:  QR146.76
P1,328.09
List Price:  P1,859.38
You save:  P531.29
KSh12,903.70
List Price:  KSh18,065.70
You save:  KSh5,162
E£4,996.50
List Price:  E£6,995.30
You save:  E£1,998.80
ብር15,702.76
List Price:  ብር21,984.50
You save:  ብር6,281.73
Kz91,195.12
List Price:  Kz127,676.82
You save:  Kz36,481.70
CLP$88,306.16
List Price:  CLP$123,632.16
You save:  CLP$35,326
CN¥689.95
List Price:  CN¥965.95
You save:  CN¥276
RD$6,024.06
List Price:  RD$8,433.93
You save:  RD$2,409.86
DA13,080.35
List Price:  DA18,313.02
You save:  DA5,232.66
FJ$220.92
List Price:  FJ$309.30
You save:  FJ$88.38
Q769.43
List Price:  Q1,077.23
You save:  Q307.80
GY$20,986.45
List Price:  GY$29,381.87
You save:  GY$8,395.42
ISK kr12,379.76
List Price:  ISK kr17,332.16
You save:  ISK kr4,952.40
DH924.08
List Price:  DH1,293.75
You save:  DH369.67
L1,721.44
List Price:  L2,410.09
You save:  L688.64
ден5,288.14
List Price:  ден7,403.61
You save:  ден2,115.46
MOP$808.30
List Price:  MOP$1,131.66
You save:  MOP$323.35
N$1,611.11
List Price:  N$2,255.62
You save:  N$644.50
C$3,691.52
List Price:  C$5,168.27
You save:  C$1,476.75
रु14,682.35
List Price:  रु20,555.88
You save:  रु5,873.53
S/337.21
List Price:  S/472.11
You save:  S/134.89
K431.67
List Price:  K604.35
You save:  K172.68
SAR375.25
List Price:  SAR525.37
You save:  SAR150.11
ZK1,916.03
List Price:  ZK2,682.53
You save:  ZK766.49
L441.35
List Price:  L617.91
You save:  L176.56
Kč2,096.87
List Price:  Kč2,935.70
You save:  Kč838.83
Ft33,199.21
List Price:  Ft46,480.23
You save:  Ft13,281.01
SEK kr924.20
List Price:  SEK kr1,293.92
You save:  SEK kr369.72
ARS$139,387.86
List Price:  ARS$195,148.59
You save:  ARS$55,760.72
Bs694.61
List Price:  Bs972.49
You save:  Bs277.87
COP$379,337.72
List Price:  COP$531,087.98
You save:  COP$151,750.26
₡47,211.02
List Price:  ₡66,097.32
You save:  ₡18,886.29
L2,654.65
List Price:  L3,716.62
You save:  L1,061.96
₲647,542.85
List Price:  ₲906,585.90
You save:  ₲259,043.04
$U3,841.23
List Price:  $U5,377.88
You save:  $U1,536.64
zł368.20
List Price:  zł515.50
You save:  zł147.29
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.