const object1 = {
firstName : 'Shashidhar',
lastName : 'B M ',
rollNo : 5678,
rank : 23456
}
Object.defineProperties(object1,{
property1 : {
results : 'selected'
}
});
console.log(object1.property1)
console.log(object1.firstName);
expected output
selected
shashidhar
actual output
undefined
shashidhar
You want
value
rather thanresults
to specify the property's value:See the documentation on MDN.