I am trying to write a simple function to test whether a value is an integer or not in a CasperJS script however it keeps giving me Syntax Error. The function in question is the following:
function isInteger(possibleInteger) {
var intMatchPattern = new RegExp("/^[\d]+$/");
return intMatchPattern.test(possibleInteger);
}
I see nothing wrong with this function however CasperJS refuses to work until I remove the line with ".test" on it.
Is this a known CasperJS bug (Currently using the latest 1.1.0-DEV)? Or maybe a PhantomJS bug?
You have an invisible character before the last semicolon.
You can spot this character if you copy/paste your code, for example, in vim or if you tell your editor to show hidden characters.
If you remove this character your code should run fine .
I found it out because pasting your code in Chrome javascript console I got the same error as in PhantomJS, rewriting your code by hand I didn't get any error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.