Trying to make a timer and came across this:
function timer(duration){
var timer = duration, minutes, seconds;
setInterval(function() {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);...
I've never seen a variable defined like this.
minutes
and seconds
are defined in setInterval callback, how is timer
getting these?
Moreover, how can timer
be more than one thing? There's something I'm missing here.
Original Fiddle
Thanks,
Danny