var map = document.getElementById("map");
var canvass = map.getContext("2d");
var i = 0;
setInterval(function () {
canvass.clearRect(0, 0, 600, 600);
canvass.fillRect(i, 0, 40, 40);
canvass.stroke();
i = i++;
console.log("fasda" + i);
}, 200);
<html>
<canvas id="map" width="600" height="600" ></canvas>
<script id="main.js">
</script>
</html>