Own and Inherited Properties
by SriSri M
JavaScript
var school = {schoolName:"Vailankanni"};
console.log('schoolName' in school);
console.log('toString' in school);
console.log(school.hasOwnProperty('schoolName'));
var car = {name:'i20',fuel:'petrol'}
delete car.fuel;
for(var eachItem in car){
console.log(eachItem);
}
var school = {schoolName:"MIT", schoolAccredited: true, schoolLocation:"Massachusetts"};
for (var eachItem in school) {
console.log(eachItem);
}
function HigherLearning () {
this.educationLevel = "University";
}
var school = new HigherLearning ();
school.schoolName = "MIT";
school.schoolAccredited = true;
school.schoolLocation = "Massachusetts";
for (var eachItem in school) {
console.log(eachItem);
}