by glesperance · 13y ago · 0 comments
I think it is convenient to be able to declare global variables like that but perhaps there should be a way to monitor those ; in other words, it would be really convenient to have some form of alert system to notify you when a new global variable is created.
That way, globals created by mistakenly forgetting the 'var' keyword would be easily spotted.
for(var i in window){ if(typeof window[i]=="object"){console.log(i);} }
But I think op wanted variables server side as well
Also, as simple as this might be, making it a de-facto standard (on meteor) would be a good thing since it would be a tool that we can count on, all the time. There are too many browsers IMO to make an extension a viable option.
Whitelisting variables would be good as well ; that way we do not get alerted if it is something we expect to be global.
Meteor.setInterval(function(){ for(var i in global){ if(MyVars.find({name:i}).count()==0){ MyVars.insert({name:i}); console.log("New Public Variable: ", i); } } }, 5000);
Thanks for the fun challenge :-)
Object.observe(window, function(changes){ console.log(changes) })
:)