javascript - How to set variables on the fly from the console? -


I would like to set the variable on the fly by using the console.

My code is wrapped in such a way:

  (function () {var debug = true; // code here} ())   

I use the debug console on the fly.

Should I move debug to populate myself and keep it in the use of global import?

Do I give the anonymous function a name, and do I set it using the name "location of name"?

I have not used the console much, but I believe that it has been made for such things.

How is this usually done? What is the best practice?

You can use a namespace with minimal effort:

  (function (efu) {foo.debug = true;} (FOO = FOO} {})); FOO.debug = false;   

I use a clear global with this sort of solution because it is not really complicated, and like with the debug variable names An opportunity is a struggle ... even if you are 100% working with your code.

Comments