Object define property

by manoj_antony32

JavaScript

var a = {
  i: 2020,
  j: 'Jan'
}

console.log(Object.getOwnPropertyDescriptor(a, 'i'))

a.i = '2019'

Object.defineProperty(a, 'i', 
{ 
	writable: false, //If its false can't modify value using equal symbol
  enumerable: false, // If its false can't able to get value in Object.keys and for in loop
  configurable: false //if its false, can't able to modify value using defineproperty while writable in false
})

//Object.defineProperty(a, 'i', { value: 2016 })

console.log(Object.keys(a))

/* console.log(Object.getOwnPropertyDescriptor(a, 'i'))

for(var i in a ) {
console.log(i)
} */