how to access value of itself object in javascript

Solutions on MaxInterview for how to access value of itself object in javascript by the best coders in the world

showing results for - "how to access value of itself object in javascript"
Brenden
17 Jan 2018
1var book  = {}
2
3Object.defineProperties(book,{
4    key1: { value: "it", enumerable: true },
5    key2: {
6        enumerable: true,
7        get: function(){
8            return this.key1 + " works!";
9        }
10    }
11});
12
13console.log(book.key2); //prints "it works!"
14