vendredi 31 juillet 2015

Access to internal object fields in Js

Having this code

var a = {date : 12};
for(var t in a){
    alert(t);
}

I have one alert with date property.

But everywhere (i.e. here) i see that it is needed to write :

for (var property in object) {
    if (object.hasOwnProperty(property)) {
        // do stuff
    }
}

So why i don't see internal properties of object?





Aucun commentaire:

Enregistrer un commentaire