1
I wonder how I can create a global variable (or global element, I don’t know what you call it) as in several plugins I see. Example in Jquery where to call any function related to it only have to instantiate the symbol #
or call for the function Jquery
before any internal function of the plugin.
I want my application to be able to call something like:
MeuElemento.Cria(args);
MeuElemento.Salvar(args);
MeuElemento.Outrafunção(args);
How do I do that? Can someone please give me an example?
I wouldn’t recommend omitting the
var
. Better use it by making sure that the variable is being declared in the overall scope. I find it less confusing.– bfavaretto
thank you very much, it will be much more organized my code rs
– LeandroLuk
@bfavaretto Do not use
var
forces the variable to stay in the global scope, but you’re right about being less confused withvar
. I’ll edit.– Oralista de Sistemas
I know how strong it is, but I always recommend never to omit :) I already mentioned it here: http://answall.com/a/2517/74. PS: thanks for Edit
– bfavaretto