Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object initializer shorthand for sub-properties? #112

Open
devuxer opened this issue Mar 1, 2018 · 0 comments
Open

Object initializer shorthand for sub-properties? #112

devuxer opened this issue Mar 1, 2018 · 0 comments

Comments

@devuxer
Copy link

devuxer commented Mar 1, 2018

[QUESTION]

Is there any way to shorten the following with ES6 features?

return { op: this.op, lhs: this.lhs, rhs: this.rhs };

I was hoping I could do something like this...

return { this.op, this.lhs, this.rhs };

...but that results in a syntax error.

It is possible to do this...

const { op, lhs, rhs } = this;
return { op, lhs, rhs };

...but that's still a bit verbose (you have to repeat {op, lhs, rhs} twice, which becomes inefficient with longer or more properties).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant