Tuesday, July 2, 2013

An Instanceof learning ...see what I did there??

Hello!  Well today was mostly filled with wedding planning stuff, but I *did* manage to squeeze in some time to read my book (thanks again WonderS!!) and do a bit more on Codecademy.  Today I learned the JavaScript operator 'Instanceof '  The syntax goes:
object instanceof constructor
Basically it is used as a test to see if the object you have created is truly an instance of a prior constructor.  For example, if you had just made a constructor Car, and now you wanted to make a constructor electricCar you could use the notation:
ElectricCar.prototype = new Car ();
then you could use instanceof to test if ElectricCar had inherited all the atributes of Car.  :D  Pretty awesome, huh? Well that's all for me today! 

0 comments:

Post a Comment