My script is as follows:
<script>
var lastTime = 0;
function loop(time) {
console.log(time);
var delay = time–lastTime;
var fps = 1000/delay;
console.log(delay + ' ms');
updateAnimation();
mozRequestAnimationFrame(loop);
lastTime = time;
}
//loop(200000);
requestAnimationFrame(loop);
</script>
When I run it under firefox with the Web console feature - I get:
SyntaxError: illegal character
on the line
var delay = time–lastTime;
Whats wrong with that line?
My script is as follows:
<script>
var lastTime = 0;
function loop(time) {
console.log(time);
var delay = time–lastTime;
var fps = 1000/delay;
console.log(delay + ' ms');
updateAnimation();
mozRequestAnimationFrame(loop);
lastTime = time;
}
//loop(200000);
requestAnimationFrame(loop);
</script>
When I run it under firefox with the Web console feature - I get:
SyntaxError: illegal character
on the line
var delay = time–lastTime;
Whats wrong with that line?
Share Improve this question asked Dec 4, 2013 at 10:04 BushBush 2,5335 gold badges36 silver badges59 bronze badges4 Answers
Reset to default 6Your dash is character code U+2013
, also called em dash, translated to an HTML entity it would be –
.
You should use the normal U+002D
or a hyphen minus.
This site has a lot of good information for you regarding this.
You probably copy pasted this from a WordPress blog or another website that translates characters into "pretty characters". Switch the –
character out with a dash instead -
.
It looks as though the dash in
var delay = time–lastTime;
isn't a minus sign. Try replacing it with -
.
You copied and pasted from somewhere. Try using the -(minus)
symbol. Because time–lastTime
doesn't contain minus symbol
time-lastTime; // use - (minus) sybmol