4 ms·
> Let's say someone is using your library within that function and you reference undefined. You get the string "oops". Oops indeed. That is incorrect. It might
by drostie 13y ago
> Let's say someone is using your library within that function and you reference undefined. You get the string "oops". Oops indeed.
That is incorrect. It might be correct if the word 'library' was replaced by 'code snippet' to indicate a copy-and-paste-of-your-code issue. But if you've created a library then your functions are over in some other file, where `typeof undefined === "undefined"`.
The proper attitude here is the same as the Python attitude towards not having `private` attributes: "If some other programmers want to do something crazy with my code, that's their prerogative. If it blows up in their faces, that's their problem."
- lmm 13y agoI used to believe this, but I now realise it's insufficient when building large apps. Upgrading the version of Django (or indeed Rails) you depend on requires a comprehensive testsuite and involves changes to your code. Upgrading the version of Wicket you depend on is easy because the framework is able to enforce that you only access the attributes you're meant to, only subclass things that are designed to be extended, etc.
- kaoD 13y agoEven if it was in the same file, as long as it's in a different function it'll work. If `undefined` is an argument name, it's only bound inside that function and nowhere else.