hasOwnProperty example

by obobruyko

JavaScript

var Mammal = function(name) {
    this.name = name;
};

var Cat = function(){
    this.saying = 'meow';
};

Cat.prototype = new Mammal();

var cat = new Cat();

for(var p in cat) {
   //if(cat.hasOwnProperty(p)) {
   //if(typeof cat[p] !== "undefined"){
       console.log(p + ": " + cat[p] + "\n");
   //}
}
//console.log(typeof cat.name);
//console.log(typeof cat.saying);