GetOwnPropertyDescriptor - Throught this key we can control our objects properties.
For example these keys controlled by users if it should be - Configurable, Enumerable, Writable.
let change={
name:'Arda',
theme:'Magic'
}
let result=Object.getOwnPropertyDescriptor(change, 'name');
console.log(result);
## Writable
it is possable to type value again if we put true.
## Enumerable
Throught this value we can control loops - for in and for of works or not.
## Configurable
This key can remove and change object values.
## DefineProperty
This method also give pirmession or not to change object
let change={
name:'Arda',
theme:'Magic'
}
Object.defineProperty(change, 'theme', {
value:"Netlify",
enumerable:false,
writable:false,
configurable:false
});
change.smth='ok'
console.log(change);
for(let key in change){
console.log('new',change[key]);
}
in this case we change object theme to Netlify and use for in and show each property and finally we should say that if we have not to change we will control it from js.
Top comments (0)