javascript - Why error occured when remove some lines of code? -
javascript - Why error occured when remove some lines of code? -
the next code working expected
class="snippet-code-js lang-js prettyprint-override">obj = { go: function() { alert(this) } } obj.go(); // object (obj.go)(); // object (a = obj.go)(); // window (0 || obj.go)(); // window
but why error occurred when comment origin 2 lines?
class="snippet-code-js lang-js prettyprint-override">obj = { go: function() { alert(this) } } //obj.go(); // commented line //(obj.go)(); // commented line (a = obj.go)(); // window (0 || obj.go)(); // window
i didn't alter of code above, comment 2 lines separate others, browser gives me error information? please clarify me? many thanks.
you have (
after }
trying phone call result of evaluating block if function.
before that, however, trying evaluate a = obj.go
can passed argument.
since obj
hasn't been defined yet (because result of calling "function" hasn't been passed obj
), throws error.
javascript html
Comments
Post a Comment