Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 1
    no. You cannot. Also I doubt you really want that. Your example would work with res1 = { getValue() { this._value; } }; though. Commented Mar 19, 2020 at 18:09
  • 1
    @JonasWilms getValue or valueOf ? Commented Mar 19, 2020 at 18:24
  • 1
    valueOf, it's late ... Commented Mar 19, 2020 at 18:24
  • @JonasWilms the valueOf advice seems to do the job for me. It even works if _value is an actual object, not just primitives. Why do you say you doubt I really want that? Are there any downsides to using it like that? Commented Mar 19, 2020 at 18:44
  • 1
    The approach of caching calls only works for Google Analytics because they are known not to return anything. Commented Mar 19, 2020 at 19:51