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
1

There are 1 answers

0
Robin Zigmond On BEST ANSWER

You want value rather than results to specify the property's value:

const object1 = {
    firstName : 'Shashidhar',
    lastName : 'B M ',
    rollNo : 5678,
    rank : 23456
}

Object.defineProperties(object1,{
    property1 : {
    value : 'selected'
    }
});


console.log(object1.property1)
console.log(object1.firstName);

See the documentation on MDN.