var canvas = document.getElementById("canvasID");

canvas.toBlob(function(blob) {

var a = document.createElement("a");
var body = document.getElementsByTagName("body");
document.body.appendChild(a);
a.download = "img" + ".jpg";
a.href = window.URL.createObjectURL(blob);

a.click();
body.removeChild("a");

});