Expressions and patterns
Getter syntax
Defines a function invoked by a property read, with zero formal parameters and the original property receiver.
Formal Syntax & Structure
javascript syntaxjavascript
get name() { /* return value */ }Working Example
Example Snippetjavascript
const o={n:2,get twice(){return this.n*2;}};console.log(o.twice);