I am getting some errors via jslint that I need assistance with:
-
Bad Escapement:
replace(‘/[^a-zA-Z0-9ñÑáÁéÉíÍóÓúÚüÜ¡¿\s+{0}]/g’, ”)
-
Empty block:
$(‘#myElement’).keydown(function (event) {
if (allowAlphaNumeric(event)) {
}
}); -
Unexpected use of ‘|’
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
Anyone have any ideas how I resolve these?
Bad Escapement:
You’re giving
replacea string containing a regular expression literal. You almost certainly want to just make it a regular expression literal:That’s certainly the case if the
replacein question isString#replace, which I’m assuming it is. If it’s something else (it would have been handy to know that) and you really want it to be a string, then just make sure you double up any backslashes within the string —\sis not a valid string escape, it’s a regular expression construct. So you’d want\\sthere so that the string ends up containing the\followed by thes. But again, I think you want the literal (where you wouldn’t do that).Empty block:
Put something in the block:
Unexpected use of ‘|’
This one looks fine to me syntactically (logically, see note below), since you really do want the bitwise operator there. Just jslint not understanding your intent.
But, um, isn’t
x | 0the same asx? Couldn’t you just remove that?