You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
Is it possible to combine optional chaining operator and shorthand access for private property ? - I assume the answer is No and use this?.#x?
Related to Call semantics #85 : in the below defined method foo, #x and this.#x should refer to the same private field of instance p.
classA{
#x;constructor(x,a){
#x=x;this.foo=this.foo.bind(a);}foo(){console.log(this?.#x);// optional chaining - logs undefined for `p.foo()`// Possible to use optional chaining for #x ?// And does this.#x and #x refer to same thing?console.log(#x,this.#x);// both should throw for `p.foo()`}}constp=newA(10);constq=newA(20,p);p.foo();// should throw here?q.foo();
The text was updated successfully, but these errors were encountered:
We haven't worked out the interaction yet, though. As this proposal is more advanced than that one, I expect it will be worked out as part of advancing it, rather than here.
@boopathi To answer the question, I think we could add a x?.#y operator (as described in #78), but the optional chaining proposal is evolving towards including only useful operations, and it's a bit hard for me to believe that this is a useful combination.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Call semantics and Usage with optional chaining proposal
this?.#x
?foo
,#x
andthis.#x
should refer to the same private field of instancep
.The text was updated successfully, but these errors were encountered: