Possible Duplicate:
SyntaxError: Unexpected token ILLEGAL
Can someone tell me why these errors are occurring and what to do to fix them?
/*global $:false */
Blah.BlahBlah = {
findLinks : function () {
"use strict";
$('a').filter(function () {
return !(/https?:\/\/[^\/]*xyz.*/i.test($(this).attr('href')));
}).text("***");
}
};
Throws these errors in JSHint :
- Line 10: } Unexpected ''.
- Line 11: }; Expected '}' to match '{' from line 3 and instead saw ';'.
- Line 11: }; Missing semicolon.
Chrome console shows this error:
- Uncaught SyntaxError: Unexpected token ILLEGAL
However, using this code (JSFiddle) in an encapsulated anonymous function does not throw an error:
/*global $:false */
(function() {
"use strict";
$('a').filter(function() {
return !(/https?:\/\/[^\/]*xyz.*/i.test($(this).attr('href')));
}).text("***");
}());