r/javascript • • Aug 27 '16

Is your JavaScript function actually pure?

http://staltz.com/is-your-javascript-function-actually-pure.html
8 Upvotes

48 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Aug 27 '16

[deleted]

1

u/vinnl Aug 28 '16

I think the main point is not that you should or could breach the contract, but rather to make you aware of the implicit parts of the contract, and how you can make some parts of it explicit as desired. For example, passing undefined or null when an actual value is expected is a breach of contract that does happen in practice, so you might want to defend against that.

1

u/neophilus77 Aug 29 '16

You shouldn't have to defend against bad data, bad data is a symptom of a bug somewhere else

1

u/vinnl Aug 30 '16

Yes, and that bug will surface if the data is rejected as soon as possible.