Everything is An Object

4 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$39.99
List Price:  $79.99
You save:  $40
€34.51
List Price:  €69.04
You save:  €34.52
£30.03
List Price:  £60.08
You save:  £30.04
CA$56.07
List Price:  CA$112.15
You save:  CA$56.08
A$61.64
List Price:  A$123.30
You save:  A$61.66
S$51.95
List Price:  S$103.92
You save:  S$51.96
HK$310.72
List Price:  HK$621.52
You save:  HK$310.80
CHF 31.86
List Price:  CHF 63.74
You save:  CHF 31.87
NOK kr401.91
List Price:  NOK kr803.93
You save:  NOK kr402.01
DKK kr257.81
List Price:  DKK kr515.68
You save:  DKK kr257.87
NZ$69.66
List Price:  NZ$139.35
You save:  NZ$69.68
د.إ146.86
List Price:  د.إ293.76
You save:  د.إ146.90
৳4,885.14
List Price:  ৳9,771.51
You save:  ৳4,886.36
₹3,508.98
List Price:  ₹7,018.84
You save:  ₹3,509.86
RM169.15
List Price:  RM338.35
You save:  RM169.20
₦58,662.13
List Price:  ₦117,338.93
You save:  ₦58,676.80
₨11,327.80
List Price:  ₨22,658.43
You save:  ₨11,330.63
฿1,315.63
List Price:  ฿2,631.59
You save:  ฿1,315.96
₺1,678.63
List Price:  ₺3,357.69
You save:  ₺1,679.05
B$215.47
List Price:  B$430.99
You save:  B$215.52
R698.96
List Price:  R1,398.11
You save:  R699.14
Лв67.44
List Price:  Лв134.89
You save:  Лв67.45
₩57,256.54
List Price:  ₩114,527.40
You save:  ₩57,270.86
₪131.86
List Price:  ₪263.76
You save:  ₪131.89
₱2,337.73
List Price:  ₱4,676.05
You save:  ₱2,338.31
¥6,071.28
List Price:  ¥12,144.08
You save:  ¥6,072.80
MX$735.85
List Price:  MX$1,471.89
You save:  MX$736.04
QR145.92
List Price:  QR291.87
You save:  QR145.95
P534.01
List Price:  P1,068.15
You save:  P534.14
KSh5,164.70
List Price:  KSh10,330.70
You save:  KSh5,166
E£1,901.52
List Price:  E£3,803.52
You save:  E£1,902
ብር6,038.47
List Price:  ብር12,078.45
You save:  ብር6,039.98
Kz36,470
List Price:  Kz72,949.12
You save:  Kz36,479.12
CLP$37,975.70
List Price:  CLP$75,960.90
You save:  CLP$37,985.20
CN¥284.92
List Price:  CN¥569.92
You save:  CN¥285
RD$2,547.56
List Price:  RD$5,095.76
You save:  RD$2,548.20
DA5,206.89
List Price:  DA10,415.09
You save:  DA5,208.20
FJ$91.93
List Price:  FJ$183.88
You save:  FJ$91.95
Q306.63
List Price:  Q613.34
You save:  Q306.71
GY$8,375.76
List Price:  GY$16,753.62
You save:  GY$8,377.85
ISK kr4,894.77
List Price:  ISK kr9,790.77
You save:  ISK kr4,896
DH368.81
List Price:  DH737.71
You save:  DH368.90
L679.76
List Price:  L1,359.69
You save:  L679.93
ден2,126.49
List Price:  ден4,253.52
You save:  ден2,127.02
MOP$320.46
List Price:  MOP$641
You save:  MOP$320.54
N$693.29
List Price:  N$1,386.76
You save:  N$693.46
C$1,473.12
List Price:  C$2,946.62
You save:  C$1,473.49
रु5,632.10
List Price:  रु11,265.62
You save:  रु5,633.51
S/135.05
List Price:  S/270.14
You save:  S/135.08
K170.84
List Price:  K341.73
You save:  K170.89
SAR149.97
List Price:  SAR299.99
You save:  SAR150.01
ZK905.77
List Price:  ZK1,811.78
You save:  ZK906
L175.43
List Price:  L350.90
You save:  L175.47
Kč839.13
List Price:  Kč1,678.47
You save:  Kč839.34
Ft13,432.80
List Price:  Ft26,868.96
You save:  Ft13,436.16
SEK kr377.49
List Price:  SEK kr755.09
You save:  SEK kr377.59
ARS$58,276.64
List Price:  ARS$116,567.85
You save:  ARS$58,291.21
Bs276.63
List Price:  Bs553.33
You save:  Bs276.69
COP$155,770.71
List Price:  COP$311,580.38
You save:  COP$155,809.66
₡20,093.12
List Price:  ₡40,191.28
You save:  ₡20,098.15
L1,051.86
List Price:  L2,103.99
You save:  L1,052.12
₲283,589.36
List Price:  ₲567,249.64
You save:  ₲283,660.27
$U1,592.21
List Price:  $U3,184.83
You save:  $U1,592.61
zł146.09
List Price:  zł292.22
You save:  zł146.12
Already have an account? Log In

Transcript

Now that you understand objects much better, I have a shocking truth for you. Everything in JavaScript is an object. And what they mean is that literally everything in JavaScript is an object. I'm going to prove it to you so that you understand it even much better. Strings are objects, integers, or numbers are objects, even functions are objects. And I'm going to show you now, for example, suppose that we have a variable called texts.

And it's equal to just the simple texts. For example, this is my text. And if I want to print this on the screen, I would just use console dot log, and I can just pass texts, right and if I see one run, I get the My text, right? And you think now that this is just a simple variable, and that is not true. The truth is that text, this string is an object. Because if you create, if you create a VAR text one, for example, equals to new, and then string, and then you add here, you add the text that you want to print.

Let's copy and paste this inside. And then you pass text one instead of text. If I save and run, I am going to get this is my text. And it's through. It's a string. And as you can see now, strings are objects.

But why would we use this version and not this the other version with the new string that makes it clear that it's an object because the first version which is This one is much easier. Why would we use some something a little bit difficult van just using this. Always go for the easier method, and also integers or numbers or objects. And I'm going to show you that for a H equals 223. Right? This is a simple variable.

If I print it, I'm going to get 23. And we know that but this is actually an object. If I create another variable called age one equals to new and then number and then I pass 23. And then I change this from h1 to from h to h one. And if I say one run, I am going to get 23 and the type is number. So this is a fact this is a fact in JavaScript.

Is that everything in JavaScript is an object. And I'm going to show you also a very interesting thing, which is that you can get the type of a variable using type of function, just type type off. And then you just pass the object or the type or value that we want to get its type. So for example, age one, if I save and run, I am going to get object because it's an object. And for example, text one, I am going to get also that it's an object. And if I use text only text and Save and Run, I am going to get that this is a string.

Now it's more specific, because text because a string is an object, but here it says string. It did not say object because it's now more specific, but it's actually an object. So here, if I Use age only age, I'm gonna get number not an object, but it's actually an object, but it's more specific. So to make things clear, an object is kind of the king. So an object is just kind of the king or the Father, and other values like strings, integers, or numbers, Booleans functions. All of these kind of sons have that King.

So they have the same behavior, so they behave the same. That's why they are objects as well by inheritance.

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.