global variables

Along the way of developing my solution I clean up things every once and a while.

Now I noticed that it is very easy to delete a global without any issue. But ok, that’s my own mistake. I should have paid more attention :D

But, when a global variable is not defined but I try to set it there is no error message.

Also when I try to get the value one gets a null value and outputting it to the debugger with application.output(global.variable) gives the message undefined…

Can we please get an error message if the global variable is not there?

we can do 2 things.

1> throw an error if you set something in the globalscope that isn’t there as a real global..

2> just add it in the globalscope so you can use it further on.

We can’t do anything about getting a global that isn’t there.
That is just how javascript works.. (returning undefined (null))

Do i understand this correctly: does option 2 give you the option for dynamically create a global variable? Would be a handy option…

Paul

If I understand correct something like global.variable = false can throw an error if global.variable it non existing?

If so, I prefer this…

we discussed this and we prefer also option 2..

so you can say:

globals.XXXX = ‘YYYY’

because that is much neater then for example just saying

XXXX = ‘YYYY’

and then use XXXX all over the place..

with the globals prefix you know what you doing and is much more structured..