Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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!"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #access #object #javascript
ADD COMMENT
Topic
Name
9+7 =