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.85
List Price:  €120.20
You save:  €34.34
£75.29
List Price:  £105.42
You save:  £30.12
CA$139.53
List Price:  CA$195.35
You save:  CA$55.82
A$151.91
List Price:  A$212.69
You save:  A$60.77
S$129.50
List Price:  S$181.31
You save:  S$51.80
HK$778.39
List Price:  HK$1,089.78
You save:  HK$311.38
CHF 80.17
List Price:  CHF 112.24
You save:  CHF 32.07
NOK kr1,009.31
List Price:  NOK kr1,413.07
You save:  NOK kr403.76
DKK kr641.25
List Price:  DKK kr897.78
You save:  DKK kr256.52
NZ$174.13
List Price:  NZ$243.80
You save:  NZ$69.66
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,191.62
List Price:  ৳17,068.76
You save:  ৳4,877.13
₹9,019.51
List Price:  ₹12,627.67
You save:  ₹3,608.16
RM412.50
List Price:  RM577.52
You save:  RM165.02
₦144,457.55
List Price:  ₦202,246.35
You save:  ₦57,788.80
₨28,185.33
List Price:  ₨39,460.59
You save:  ₨11,275.26
฿3,192.33
List Price:  ฿4,469.39
You save:  ฿1,277.06
₺4,244.10
List Price:  ₺5,941.91
You save:  ₺1,697.81
B$533.64
List Price:  B$747.12
You save:  B$213.48
R1,710
List Price:  R2,394.08
You save:  R684.07
Лв167.98
List Price:  Лв235.18
You save:  Лв67.20
₩146,538.35
List Price:  ₩205,159.56
You save:  ₩58,621.20
₪324.13
List Price:  ₪453.80
You save:  ₪129.66
₱5,891.26
List Price:  ₱8,248
You save:  ₱2,356.74
¥15,560.70
List Price:  ¥21,785.61
You save:  ¥6,224.90
MX$1,826.45
List Price:  MX$2,557.10
You save:  MX$730.65
QR364.65
List Price:  QR510.53
You save:  QR145.87
P1,333.36
List Price:  P1,866.76
You save:  P533.39
KSh12,943.70
List Price:  KSh18,121.70
You save:  KSh5,178
E£4,751.35
List Price:  E£6,652.08
You save:  E£1,900.73
ብር15,409.57
List Price:  ብር21,574.01
You save:  ብር6,164.44
Kz91,216.93
List Price:  Kz127,707.36
You save:  Kz36,490.42
CLP$92,386.76
List Price:  CLP$129,345.16
You save:  CLP$36,958.40
CN¥706.37
List Price:  CN¥988.95
You save:  CN¥282.58
RD$6,298.13
List Price:  RD$8,817.64
You save:  RD$2,519.50
DA13,013.32
List Price:  DA18,219.18
You save:  DA5,205.85
FJ$226.58
List Price:  FJ$317.23
You save:  FJ$90.64
Q764.28
List Price:  Q1,070.03
You save:  Q305.74
GY$20,873.29
List Price:  GY$29,223.44
You save:  GY$8,350.15
ISK kr12,774.72
List Price:  ISK kr17,885.12
You save:  ISK kr5,110.40
DH923.18
List Price:  DH1,292.49
You save:  DH369.31
L1,699.07
List Price:  L2,378.77
You save:  L679.69
ден5,295.87
List Price:  ден7,414.43
You save:  ден2,118.56
MOP$800.14
List Price:  MOP$1,120.23
You save:  MOP$320.08
N$1,708.62
List Price:  N$2,392.14
You save:  N$683.51
C$3,671.47
List Price:  C$5,140.21
You save:  C$1,468.73
रु14,362.10
List Price:  रु20,107.51
You save:  रु5,745.41
S/336.50
List Price:  S/471.11
You save:  S/134.61
K422.99
List Price:  K592.21
You save:  K169.21
SAR375.24
List Price:  SAR525.35
You save:  SAR150.11
ZK2,292.25
List Price:  ZK3,209.25
You save:  ZK916.99
L436.93
List Price:  L611.72
You save:  L174.79
Kč2,071.96
List Price:  Kč2,900.84
You save:  Kč828.87
Ft32,683.18
List Price:  Ft45,757.76
You save:  Ft13,074.58
SEK kr939.74
List Price:  SEK kr1,315.68
You save:  SEK kr375.93
ARS$145,633.56
List Price:  ARS$203,892.81
You save:  ARS$58,259.25
Bs689.44
List Price:  Bs965.25
You save:  Bs275.80
COP$379,711.65
List Price:  COP$531,611.50
You save:  COP$151,899.85
₡49,130.59
List Price:  ₡68,784.79
You save:  ₡19,654.20
L2,628.55
List Price:  L3,680.08
You save:  L1,051.52
₲691,938.08
List Price:  ₲968,741
You save:  ₲276,802.91
$U3,934.14
List Price:  $U5,507.95
You save:  $U1,573.81
zł363.22
List Price:  zł508.52
You save:  zł145.30
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.