Skip to content Skip to sidebar Skip to footer

Javascript Crash After Removing Any Trivial Statement

I'm working on a short JavaScript program, which works perfectly fine ONLY if I inject any trivial statement--such as var asd;--at a specific location. The program is intended to d

Solution 1:

When you do

MyApp.util.toXML = function(options, obj) {
}

(function(){
}());

you are actually invoking the function

MyApp.util.toXML = function(options, obj) {
}( function(){}()) );

Solution 2:

You are forgetting the ; after the function definition

MyApp.util.toXML = function() {
 // code
}; // this semicolon

Solution 3:

Solution 4:

http://jsfiddle.net/bZUm6/8/

You're missing a semicolon after the function. I suppose it evaluates to something else if you don't end the statement.

Post a Comment for "Javascript Crash After Removing Any Trivial Statement"