instanceof Operator

2 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
€84.46
List Price:  €118.25
You save:  €33.79
£73.27
List Price:  £102.58
You save:  £29.31
CA$137.74
List Price:  CA$192.84
You save:  CA$55.10
A$150.28
List Price:  A$210.40
You save:  A$60.11
S$127.86
List Price:  S$179.01
You save:  S$51.15
HK$777.68
List Price:  HK$1,088.79
You save:  HK$311.10
CHF 78.77
List Price:  CHF 110.28
You save:  CHF 31.51
NOK kr980.74
List Price:  NOK kr1,373.07
You save:  NOK kr392.33
DKK kr630.47
List Price:  DKK kr882.69
You save:  DKK kr252.21
NZ$169.27
List Price:  NZ$236.99
You save:  NZ$67.71
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,185.31
List Price:  ৳17,059.92
You save:  ৳4,874.61
₹8,811.41
List Price:  ₹12,336.33
You save:  ₹3,524.92
RM419.55
List Price:  RM587.39
You save:  RM167.84
₦149,429.05
List Price:  ₦209,206.65
You save:  ₦59,777.60
₨28,401.48
List Price:  ₨39,763.21
You save:  ₨11,361.73
฿3,178.98
List Price:  ฿4,450.70
You save:  ฿1,271.72
₺4,131.33
List Price:  ₺5,784.03
You save:  ₺1,652.69
B$533.15
List Price:  B$746.44
You save:  B$213.28
R1,735.26
List Price:  R2,429.44
You save:  R694.17
Лв165.36
List Price:  Лв231.51
You save:  Лв66.15
₩138,526.83
List Price:  ₩193,943.10
You save:  ₩55,416.27
₪334.31
List Price:  ₪468.04
You save:  ₪133.73
₱5,702.16
List Price:  ₱7,983.25
You save:  ₱2,281.09
¥14,726.04
List Price:  ¥20,617.04
You save:  ¥5,891
MX$1,826.26
List Price:  MX$2,556.84
You save:  MX$730.57
QR365
List Price:  QR511.02
You save:  QR146.01
P1,418.71
List Price:  P1,986.26
You save:  P567.54
KSh12,913.70
List Price:  KSh18,079.70
You save:  KSh5,166
E£4,817.39
List Price:  E£6,744.55
You save:  E£1,927.15
ብር14,488.01
List Price:  ብር20,283.80
You save:  ብር5,795.78
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$95,246.47
List Price:  CLP$133,348.87
You save:  CLP$38,102.40
CN¥710.50
List Price:  CN¥994.74
You save:  CN¥284.23
RD$6,225.40
List Price:  RD$8,715.82
You save:  RD$2,490.41
DA12,927.13
List Price:  DA18,098.50
You save:  DA5,171.37
FJ$224
List Price:  FJ$313.61
You save:  FJ$89.61
Q766.66
List Price:  Q1,073.36
You save:  Q306.69
GY$20,938.51
List Price:  GY$29,314.75
You save:  GY$8,376.24
ISK kr12,061.79
List Price:  ISK kr16,886.99
You save:  ISK kr4,825.20
DH898.43
List Price:  DH1,257.84
You save:  DH359.41
L1,653.42
List Price:  L2,314.85
You save:  L661.43
ден5,203.15
List Price:  ден7,284.62
You save:  ден2,081.46
MOP$801.62
List Price:  MOP$1,122.31
You save:  MOP$320.68
N$1,740.46
List Price:  N$2,436.72
You save:  N$696.25
C$3,682.88
List Price:  C$5,156.18
You save:  C$1,473.30
रु14,057.89
List Price:  रु19,681.61
You save:  रु5,623.72
S/348.15
List Price:  S/487.43
You save:  S/139.27
K418.35
List Price:  K585.71
You save:  K167.35
SAR375.03
List Price:  SAR525.06
You save:  SAR150.02
ZK2,344.31
List Price:  ZK3,282.12
You save:  ZK937.81
L428.13
List Price:  L599.40
You save:  L171.27
Kč2,054.61
List Price:  Kč2,876.54
You save:  Kč821.93
Ft32,836.53
List Price:  Ft45,972.46
You save:  Ft13,135.92
SEK kr927.58
List Price:  SEK kr1,298.65
You save:  SEK kr371.07
ARS$147,359.02
List Price:  ARS$206,308.52
You save:  ARS$58,949.50
Bs691.58
List Price:  Bs968.24
You save:  Bs276.65
COP$386,929.40
List Price:  COP$541,716.65
You save:  COP$154,787.24
₡50,433.99
List Price:  ₡70,609.61
You save:  ₡20,175.61
L2,624.11
List Price:  L3,673.86
You save:  L1,049.75
₲714,143.32
List Price:  ₲999,829.21
You save:  ₲285,685.89
$U3,999.43
List Price:  $U5,599.36
You save:  $U1,599.93
zł359.58
List Price:  zł503.43
You save:  zł143.84
Already have an account? Log In

Transcript

Hello in this JavaScript video I am going to demonstrate the instance of operator. So this is fantastic if you want to check if you know this instance is object is of a particular class. And you can do that using the instance of operator. So all I'll do is I'll get rid of this for this video. So here, I'm going to create a variable on say is invalid. So this will store true or false, if the actual core object is you know of color class.

And to check this You nearly immediately specify the name of your objects of color OBJ for example, instance of then the name of your class which is call and we can print this to false is better return because it is of that class and we reload. We Get true. Okay guys, testicle. Let me just quickly create a new Java class. I'm not gonna put anything in there, because all I want to do is just create an object of this class and check if it is a call and we will get a false result. And we don't actually even put a constructor.

We don't put a constructor, he creates one by default, so we don't need to worry about that. If I create a log on OBJ equals new like so. And now if I do that, I think is valid to say if the boy OBJ is an instance of a call which we know to be false. We should get to the first line because a call OBJ is a car is you know created by the contrast From the car class, and the bike OBJ isn't instance of car because it's an instance of bike. If I reload, we get false. And that's it.

That's when you the instance operator to determine if a particular object is of a certain class. That's it. If you have any questions, feel free to shoot me a message. And as usual, I look forward seeing you in the next video.

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.