Thursday, July 30, 2015

.hasOwnProperty in JavaScript

...does what you'd expect. The following example returns two alerts, the first saying "true" and the second saying "false"

var burningMan = {
   wickerColossusOnFire : "burn baby burn"
};
alert(burningMan.hasOwnProperty("wickerColossusOnFire"));
alert(burningMan.hasOwnProperty("wickerColossusAfterFire"));

 
 

This is another something I learned from Kyle Simpson's book "this & OBJECT PROTOTYPES"

No comments:

Post a Comment