Context - Discussion

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
€85.14
List Price:  €119.21
You save:  €34.06
£74.68
List Price:  £104.56
You save:  £29.87
CA$137.64
List Price:  CA$192.70
You save:  CA$55.06
A$150.39
List Price:  A$210.55
You save:  A$60.16
S$128.91
List Price:  S$180.48
You save:  S$51.56
HK$778.15
List Price:  HK$1,089.44
You save:  HK$311.29
CHF 79.60
List Price:  CHF 111.44
You save:  CHF 31.84
NOK kr1,012.71
List Price:  NOK kr1,417.84
You save:  NOK kr405.12
DKK kr636.06
List Price:  DKK kr890.52
You save:  DKK kr254.45
NZ$172.81
List Price:  NZ$241.94
You save:  NZ$69.13
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,214.34
List Price:  ৳17,100.57
You save:  ৳4,886.22
₹9,071.34
List Price:  ₹12,700.24
You save:  ₹3,628.90
RM409.20
List Price:  RM572.90
You save:  RM163.70
₦145,133.48
List Price:  ₦203,192.68
You save:  ₦58,059.20
₨28,011.26
List Price:  ₨39,216.89
You save:  ₨11,205.62
฿3,142.13
List Price:  ฿4,399.11
You save:  ฿1,256.98
₺4,269.71
List Price:  ₺5,977.76
You save:  ₺1,708.05
B$541.91
List Price:  B$758.70
You save:  B$216.78
R1,681.81
List Price:  R2,354.61
You save:  R672.79
Лв166.53
List Price:  Лв233.15
You save:  Лв66.62
₩146,386.44
List Price:  ₩204,946.87
You save:  ₩58,560.43
₪321.04
List Price:  ₪449.47
You save:  ₪128.43
₱5,894.51
List Price:  ₱8,252.55
You save:  ₱2,358.04
¥15,495.23
List Price:  ¥21,693.94
You save:  ¥6,198.71
MX$1,797.13
List Price:  MX$2,516.05
You save:  MX$718.92
QR364.26
List Price:  QR509.98
You save:  QR145.72
P1,324.33
List Price:  P1,854.12
You save:  P529.78
KSh12,892.71
List Price:  KSh18,050.31
You save:  KSh5,157.60
E£4,748.49
List Price:  E£6,648.08
You save:  E£1,899.58
ብር15,617.37
List Price:  ብር21,864.95
You save:  ብር6,247.57
Kz91,205.27
List Price:  Kz127,691.03
You save:  Kz36,485.76
CLP$91,340.86
List Price:  CLP$127,880.86
You save:  CLP$36,540
CN¥704.64
List Price:  CN¥986.53
You save:  CN¥281.88
RD$6,354.07
List Price:  RD$8,895.96
You save:  RD$2,541.88
DA12,968.25
List Price:  DA18,156.07
You save:  DA5,187.81
FJ$225.35
List Price:  FJ$315.50
You save:  FJ$90.15
Q765.53
List Price:  Q1,071.77
You save:  Q306.24
GY$20,910.39
List Price:  GY$29,275.38
You save:  GY$8,364.99
ISK kr12,635.73
List Price:  ISK kr17,690.53
You save:  ISK kr5,054.80
DH919.51
List Price:  DH1,287.35
You save:  DH367.84
L1,689.61
List Price:  L2,365.52
You save:  L675.91
ден5,241.56
List Price:  ден7,338.40
You save:  ден2,096.83
MOP$801.46
List Price:  MOP$1,122.07
You save:  MOP$320.61
N$1,686.27
List Price:  N$2,360.84
You save:  N$674.57
C$3,678.63
List Price:  C$5,150.23
You save:  C$1,471.59
रु14,462.40
List Price:  रु20,247.95
You save:  रु5,785.54
S/336.50
List Price:  S/471.12
You save:  S/134.61
K430.77
List Price:  K603.10
You save:  K172.32
SAR375.15
List Price:  SAR525.23
You save:  SAR150.07
ZK2,306.35
List Price:  ZK3,228.98
You save:  ZK922.63
L433.42
List Price:  L606.81
You save:  L173.38
Kč2,067.88
List Price:  Kč2,895.12
You save:  Kč827.23
Ft32,789.63
List Price:  Ft45,906.80
You save:  Ft13,117.16
SEK kr928.77
List Price:  SEK kr1,300.32
You save:  SEK kr371.54
ARS$144,063.05
List Price:  ARS$201,694.03
You save:  ARS$57,630.98
Bs690.62
List Price:  Bs966.89
You save:  Bs276.27
COP$380,273.94
List Price:  COP$532,398.74
You save:  COP$152,124.79
₡49,997.35
List Price:  ₡69,998.29
You save:  ₡20,000.94
L2,631.45
List Price:  L3,684.14
You save:  L1,052.68
₲671,370.87
List Price:  ₲939,946.08
You save:  ₲268,575.20
$U3,917.97
List Price:  $U5,485.31
You save:  $U1,567.34
zł359.24
List Price:  zł502.95
You save:  zł143.71
Already have an account? Log In

Transcript

Earlier in this class, we asked the very important question, what is context in JavaScript? And we found the answer was context is the object to which a method belongs. That discussion was fairly high levels. Let's dig in a little bit deeper. Here I have this object called account. And it has two properties, account number, which is a number and get account number, which is a function.

In JavaScript. When a property is a function. It's also called a method that happens to be true for a number of languages. But here the get account number property is a method because it's a function and that function returns the value of the account number property of this object. So in this case, it will return 12345. Now we could have just said in our get account number method, return account dot account number, but that's not very elegant.

So what we do as we say return this dot account number now since get account number is a method, the JavaScript This keyword inside of that method refers to the object to which that method belongs. And that method belongs to the account object. So the get account number method returns the account number property of whatever object it belongs to, which happens to be the account object. So when we say this dot account number, we're really saying account dot account number. So it's just really important to remember that when it comes to context, the JavaScript this keyword refers to the object to which a method belongs. Now let's dig in a little bit deeper and look at some actual code examples.

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.