I created this object and its properties:
var obj = {};
Object.defineProperty( obj, "value", {
value: true,
writable: false,
enumerable: true,
configurable: true
});
var name = "John";
Object.defineProperty( obj, "name", {
get: function(){ return name; },
set: function(value){ name = value; }
});
So, I find a for loop for them:
for ( var prop in obj ) {
console.log( prop );
}
According to my study guide you should get the following results:
value
name
But instead, it displays the value. Why doesn't the name appear?
source
share