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

Igor Kuna • 6 years ago

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

Ford Prefect • 5 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 • 4 years ago

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

jgod • 5 years ago

Strongly agree

Ken Dale • 5 years ago

Approved

Victor Posmagel • 2 years ago

+1

Sarvar • 5 years ago

Thanks man for this

ssfane • 6 years ago

geat, 10x!

Hyunjin Kim • 2 years ago

good post

BrokenByHer • 3 years ago

Thanks Sir!

Kote Isaev • 4 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 • 4 years ago

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

Tammar • 4 years ago

Neat feature!

Carlos Soares Dias • 5 years ago

Super objetive. Super effective.

David Barbakadze • 5 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 • 5 years ago

Same question here, I'd say no.

Philia Development • 4 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 • 5 years ago

1000x loved it.

Niki Herl • 5 years ago

nice, thanks.