I know that if I declare an object like:
var myObj = {
prop1 : 1,
prop2 : 2
}
I can access and manipulate it from the console by typing myObj.
If I wrap it in an anonymous self-executing function, can I still access it from the console?
(function(){
var myObj = {
prop1 : 1,
prop2 : 2
}
})();
You probably can.
For example in Chrome, you can insert a breakpoint at the correct position, then you can access (and manipulate) it.
(A fun fact of this screenshot is that your anonymous function is actually inside another anonymous function)
For Firefox I believe FireBug can do the job. IE8+ also has the functionality.