We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Igor Kuna • 4 years ago

Aaa thank you so much for this... very simply put and all I needed to know :)

Ford Prefect • 3 years ago

Honestly I do not like this use of the auto-property generation. Better to be explicit by creating private data fields and public property accessors.

Bart • 2 years ago

I like auto-property generation... who needs boilerplate code?

jgod • 3 years ago

Strongly agree

Ken Dale • 3 years ago

Approved

Victor Posmagel • 2 months ago

+1

Sarvar • 3 years ago

Thanks man for this

ssfane • 4 years ago

geat, 10x!

Hyunjin Kim • 2 months ago

good post

BrokenByHer • 1 year ago

Thanks Sir!

Kote Isaev • 2 years ago

I do not understand why we can not something similar across constructor body, like of public/private/protected used inside constructor, like public name = options.name; autodeclare field instead of typing it twise - as declaration and.at in-constructor assignment.

Gary Oberbrunner • 2 years ago

How does this work with derived classes (child extends parent)?

Tammar • 2 years ago

Neat feature!

Carlos Soares Dias • 3 years ago

Super objetive. Super effective.

David Barbakadze • 3 years ago

What if I pass my arguments as an object, can I deconstruct the object and create and assign private/public properties simultaneously?

Mathieu • 3 years ago

Same question here, I'd say no.

Philia Development • 2 years ago

The answer is no, we use a pattern where we do this, and have a `static` method for manufacturing the constructor.

e.g.
static from({prop1, prop2}) => new this(public prop1, public prop2)

Nelson Mokoena • 4 years ago

1000x loved it.

Niki Herl • 4 years ago

nice, thanks.