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.80
List Price:  €118.72
You save:  €33.92
£73.15
List Price:  £102.41
You save:  £29.26
CA$136.68
List Price:  CA$191.36
You save:  CA$54.67
A$143
List Price:  A$200.20
You save:  A$57.20
S$127.14
List Price:  S$178
You save:  S$50.86
HK$781.15
List Price:  HK$1,093.65
You save:  HK$312.49
CHF 77.69
List Price:  CHF 108.77
You save:  CHF 31.08
NOK kr967.15
List Price:  NOK kr1,354.05
You save:  NOK kr386.90
DKK kr633.35
List Price:  DKK kr886.72
You save:  DKK kr253.36
NZ$165.87
List Price:  NZ$232.22
You save:  NZ$66.35
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,214.06
List Price:  ৳17,100.18
You save:  ৳4,886.11
₹9,025.73
List Price:  ₹12,636.38
You save:  ₹3,610.65
RM393.21
List Price:  RM550.51
You save:  RM157.30
₦138,728.12
List Price:  ₦194,224.92
You save:  ₦55,496.80
₨27,951.71
List Price:  ₨39,133.51
You save:  ₨11,181.80
฿3,156.95
List Price:  ฿4,419.85
You save:  ฿1,262.90
₺4,348.14
List Price:  ₺6,087.57
You save:  ₺1,739.43
B$522.81
List Price:  B$731.96
You save:  B$209.14
R1,598.76
List Price:  R2,238.33
You save:  R639.57
Лв165.80
List Price:  Лв232.13
You save:  Лв66.32
₩144,844.20
List Price:  ₩202,787.68
You save:  ₩57,943.47
₪308.99
List Price:  ₪432.60
You save:  ₪123.60
₱5,910
List Price:  ₱8,274.24
You save:  ₱2,364.23
¥15,584.92
List Price:  ¥21,819.52
You save:  ¥6,234.59
MX$1,730.78
List Price:  MX$2,423.16
You save:  MX$692.38
QR363.42
List Price:  QR508.80
You save:  QR145.38
P1,322.22
List Price:  P1,851.16
You save:  P528.94
KSh12,898.71
List Price:  KSh18,058.71
You save:  KSh5,160
E£4,694.52
List Price:  E£6,572.51
You save:  E£1,877.99
ብር15,502.71
List Price:  ብር21,704.42
You save:  ብር6,201.70
Kz91,219.87
List Price:  Kz127,711.47
You save:  Kz36,491.60
CLP$86,330.36
List Price:  CLP$120,865.96
You save:  CLP$34,535.60
CN¥693.70
List Price:  CN¥971.20
You save:  CN¥277.50
RD$6,347.79
List Price:  RD$8,887.16
You save:  RD$2,539.37
DA12,995.80
List Price:  DA18,194.64
You save:  DA5,198.84
FJ$220.10
List Price:  FJ$308.15
You save:  FJ$88.05
Q766.59
List Price:  Q1,073.25
You save:  Q306.66
GY$20,909.94
List Price:  GY$29,274.76
You save:  GY$8,364.81
ISK kr12,296.77
List Price:  ISK kr17,215.97
You save:  ISK kr4,919.20
DH916.77
List Price:  DH1,283.52
You save:  DH366.74
L1,682.77
List Price:  L2,355.95
You save:  L673.17
ден5,226.90
List Price:  ден7,317.88
You save:  ден2,090.97
MOP$804.27
List Price:  MOP$1,126.01
You save:  MOP$321.74
N$1,600.79
List Price:  N$2,241.17
You save:  N$640.38
C$3,678.21
List Price:  C$5,149.64
You save:  C$1,471.43
रु14,704.79
List Price:  रु20,587.29
You save:  रु5,882.50
S/336.45
List Price:  S/471.05
You save:  S/134.59
K428.19
List Price:  K599.48
You save:  K171.29
SAR374.94
List Price:  SAR524.94
You save:  SAR149.99
ZK1,961.36
List Price:  ZK2,745.98
You save:  ZK784.62
L432.04
List Price:  L604.88
You save:  L172.83
Kč2,062.86
List Price:  Kč2,888.09
You save:  Kč825.23
Ft32,289.72
List Price:  Ft45,206.90
You save:  Ft12,917.18
SEK kr892.23
List Price:  SEK kr1,249.16
You save:  SEK kr356.92
ARS$144,835.52
List Price:  ARS$202,775.52
You save:  ARS$57,940
Bs696.40
List Price:  Bs975
You save:  Bs278.59
COP$362,990.69
List Price:  COP$508,201.49
You save:  COP$145,210.80
₡49,635.87
List Price:  ₡69,492.20
You save:  ₡19,856.33
L2,640.54
List Price:  L3,696.86
You save:  L1,056.32
₲663,066.42
List Price:  ₲928,319.51
You save:  ₲265,253.09
$U3,854.56
List Price:  $U5,396.54
You save:  $U1,541.97
zł357.81
List Price:  zł500.96
You save:  zł143.14
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.