Last active
February 10, 2020 22:33
-
-
Save creadone/4791d6c556995d917abd5475823cb3b7 to your computer and use it in GitHub Desktop.
JavaScript: reference to own property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Complex configuration object | |
var myObject = { | |
property1: { id: 1, name: 'value property1', handler: data => data.length }, | |
get property2(){ return { ...this.property1, id: 2 } } // ref1 | |
}; | |
// > myObject.property2 | |
// > {id: 2, name: "value property1", handler: f} | |
//------------- | |
// ref1: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another way: