How to update object properties in js?

There is an object variable, an object property is a value of the variable.
let value = 1;

const object = {
 property: value 
}
object.property; // result: 1
value = 2;
object.property; // result: 1

The problem is that the name of the variable can be different, and I can't do so

object = {
 property: value 
}
// or so
object.property = value
April 4th 20 at 00:32
1 answer
April 4th 20 at 00:34
Solution
let value = 1;
const object = {
 get property() {
 return value;
}
};

object.property; // result: 1
value = 2;
object.property; // result: 2
Thank you - Erna.Ziemann commented on April 4th 20 at 00:37

Find more questions by tags JavaScript