Canvas cannot read property of undefined
<pre><code>function getMousePos(canvas, evt) {
    var rect = canvas.getBoundingClientRect();
    return {
        x: evt.clientX - rect.left,
        y: evt.clientY - rect.top
    };
}

setInterval(function (evt) {
    if (frame &lt; 4) {
        frame += 1;
    } else {
        frame = 0;
    }
    var mousePos = getMousePos(canvas, evt);
    // ...
}, 500);
</code></pre>

<p>Hello I am new to jQuery/JavaScript, why does <code>evt.clientX</code> throws </p>

<blockquote>
  <p>cannot read property of undefined</p>
</blockquote>

<p>?</p>
