Answers for "how to access value of itself object in javascript"

1

how to access value of itself object in javascript

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!"
Posted by: Guest on June-18-2021

Code answers related to "how to access value of itself object in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language