This sounds pretty dangerous to me. Crockford has this to say http://bit.ly/r9EZO about it.
Now, maybe she was just joshing me... but I'm not taking that chance.
As I mentioned in another thread, I don't minify my application code so maybe it's not as important as it is for other people.
_obj.publicVariable = 'bar'
_obj.publicMethod = function(){}
Personally I cannot type any statement without an ending semicolon, it is a mannerism that stayed with me since I had to learn Pascal. It makes it difficult for me to do anything useful in Python and I am actually contemplating to see a therapist for this.The reason I like using _obj is because "this" is notoriously hard to work with in JS. If, inside foo(), you have an iterator that you pass a function to, "this" takes on a different meaning inside that function.
Some people are really good at working out what "this" refers to, but I'm not. So I assign the main object to _obj just to be safe.
However, I've never had a problem in the cases where I have indeed minified unsemicoloned code. Has anyone else, or is the problem just theoretical? If others have encountered an actual problem, I might have to rethink this strategy for larger codebases.
var MyObject = function() {
To me, it makes the separation of public and private methods and variables easier to observe.Also, an unrelated note: I've stopped using semicolons round about 6 months ago and have never looked back. It makes my life simpler, I'm happier, and my sex life has never been better.
EDIT: Removed syntax error (the "var" in front of "_obj.whatever")