📜  如何在javascript代码示例中访问自身对象的值

📅  最后修改于: 2022-03-11 15:02:18.190000             🧑  作者: Mango

代码示例1
var book  = {}

Object.defineProperties(book,{
    key1: { value: "it", enumerable: true },
    key2: {
        enumerable: true,
        get: function(){
            return this.key1 + " works!";
        }
    }
});

console.log(book.key2); //prints "it works!"