Small Problems Encountered by Novice in js Learning

  node.js, question

The code is here (jsBin): js,console
How can I make the function m2 execute?
After reading the answers given by several respondents, it seems that I didn’t understand the original intention of writing this code. The reason why I write this sentence is: throw new Error (‘end of program’); Because I couldn’t find exit in JavaScript that I could think of in other languages. Statement that directly exits the entire program, so I write here to throw an exception to exit the entire program. The function of my code is: subApp itself is also a function, you can also use the parameter like common functions m1 and m2, and then how to run all the methods stored in app.stack inside normally, that is to say, when running subApp, the program can know that subApp is only one method in app.stack, while there are other methods in app.stack that are not running. I wonder if you can understand what I said.


Can’t we swap places? If it is executed firstsubAppIf so, thenapp.stackIf it is empty, an error will be thrown, the program will stop, and it will definitely not be executed.m2Here we go.