Edited for clarification
I've found that different browsers have a different tolerance level towards jquer开发者_开发知识库y (javascript) errors. For example, missing a semi-colon, or giving the last element in an array a comma at the end, was ignored by some, but not by others. One issue, unique to ie8, occurred when I used .css('width',-myfunc(iwidth)) instead of .css('width',myfunc(-iwidth)). It threw unhelpful error messages involving the jquery1.4.js file.
I tried to set javascript errors to strict in firefox, but was inundated with messages to a ridiculous extent.
Is there a way to set up a strict js setting, so errors of the type mentioned before result in error messages, without a deluge?
Clarification:
Let me clarify, as people seem to have misunderstood me. I guess I came off as critising jquery, when that wasn't my real problem. My intension is not to make incorrect code work. Obviously, if I could, I'd write perfect code with zero typos and mistakes, but then I wouldn't be human. I debug my js/jquery code using different browsers and debugging addons, eg firebug on firefox. But, this, it seems, is insufficient as browsers try to fix incorrect code.
I'll try xzyfer suggestion to use jslint. Is there something like jslint I can use locally, offline on linux, if a browser is inadequate?
The issue isn't jQuery but infact that you are using it incorrectly.
You should get to know the best practices, these will prevent many of the issues you've mentioned above.
In future I would recommend first running you Javascript through the JSLint utility
Missing a semi-colon at the end of a line is a Javascript error it has nothing to do with jQuery - a browser that follows the correct conventions will break if your code isn't correct. As for the , at the end of an array... when was the last time you declared something like this in any other modern programming language and got away with it?
精彩评论