imagine you are shipping a module for use by others, and you don't want to expose internals to consumers. private methods and properties help to know that only the public API is in use, giving confidence in publishing updates or fixes.
another use case is knowing that naughty developers aren't reaching into your module and changing its behaviour. I'm sure there's more, but those are the ones that come to mind. > On 17. Apr 2018, at 08:17, kai zhu <kaizhu...@gmail.com> wrote: > > as a javascript web-developer, can someone educate me on how private > class methods/fields would make one's life easier (rather than harder) > in getting web-projects shipped? > > ``` > /* > * how is this cited example better than using a plain object in a web-project? > * can someone give actual common problems in > * debugging/integrating/shipping web-projects, > * that private methods/fields could help simplify (rather than complicate)? > */ > class HashTable { > constructor() { > private[Symbol.for('length')] = 0 > } > set(key, value) { > private[key] = value > } > get(key) { > return private[key] > } > } > ``` > _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss