(after) jquery get script success I don't see (deliberate) errors

I don't understand why I cant see errors from my script after success (I google this and it just comes up with lots of answers about error handling for the event of success/error on jquery get script).

If I do this with 'any' js script

$.getScript('myextrascript.js',function(){console.log('got it!');});

Emphasis on 'any' js script (I've tried at least 12 different scripts by different people) because after my script had an error that just stopped the script (I got no console error) my first thought was does this happen just with my code?

say for example my extra script had a deliberately undeclared variable in it...

myextrascript.js:

console.log('I can see this in the console no problem');

var declaired='this variable is ok';

undeclaired='this will cause an error';

console.log("I now don't see this console log because my code has stopped");

I would normally see the error in the console like

undeclaired is undefined       myextrascript.js:3

But I don't see errors inside my extra scripts, Not even if I put this a line before my error

window.onerror=function(e,script,line){window.console.log("Error: "+e+" ("+script+":"+ line+")");}

Don't really have anymore ideas past this, It's really puzzling.

Answers


Solved!

"use strict";

window.onerror=function(e,script,line){window.console.log("Error: "+e+" ("+script+":"+ line+")");}

undeclaired=1;

console.log('WINNING!');

I added "use strict"; and now it its working/broken (BROKEN JUST HOW I WANT!)

Error: Uncaught ReferenceError: undeclaired is not defined (myextrascript.js:12)
Uncaught ReferenceError: undeclaired is not defined


Need Your Help

Unexpected Python Arithmetic Behavior

python performance encoding decoding

I'm working on a huffman encoder/decoder in Python, and am experiencing some unexpected (at least for me) behavior in my code. Encoding the file is fine, the problem occurs when decoding the file. ...