Я пытаюсь получить "use strict"; директива на работу, и возникли небольшие проблемы. В следующем файле FireFox 9 (правильно) обнаружит, что someVar не был объявлен в строке 3, но не сможет определить, что theVar не был объявлен в строке 19. Я не понимаю, почему это так.
"use strict"; // this will cause the browser to check for errors more aggresively
someVar = 10; // this DOES get caught // LINE 3
// debugger; // this will cause FireBug to open at the bottom of the page/window
// it will also cause the debugger to stop at this line
// Yep, using jQuery & anonymous functions
$(document).ready( function(){
alert("document is done loading, but not (necessarily) the images!");
$("#btnToClick").click( function () {
alert("About to stop");
var aVariable = 1;
debugger; // stop here!
alert("post stop " + aVariable );
// this lacks a "var" declaration:
theVar = 10; // LINE 19 // this is NOT getting caught
// needs a closing "
// alert("hi);
console.log("Program is printing information to help the developer debug a problem!");
});
});