All of the above, you can simply create a nested function to replace some localized repeating code inside the function (which will be used only inside the parent function). Some may say that they simply create private methods (or smaller blocks of code), but it hides the water when the super-special task (which is exclusive to the parent) needs to be modular, but the rest of the class (or the global space in the procedural program) is not necessarily accessible . The good news is that if it turns out that you need this function somewhere else, the fix is pretty basic (move the definition to a more central place).
Generally speaking, using JavaScript as the standard for evaluating other C programming languages is a bad idea. JavaScript is certainly its own animal compared to PHP, Python, Perl, C, C ++ and Java. Of course, there are many common similarities, but the detailed detailed details (JavaScript link: The Definitive Guide, 6th Edition, chapters 1-12), when you pay attention to this, make the core JavaScript unique, beautiful, different, simple and complex all at the same time. These are my two cents.
Just to be clear, I'm not saying that nested functions are private. Just this attachment can help to avoid clutter when you need something trivial to be modular (and only a parent function is required).
Anthony Rutledge Sep 27 '15 at 1:39 on 2015-09-27 01:39
source share