Check out example codes for "javascript canvas pixel art". It will help you in understanding the concepts better.

Code Example 1

var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
window.location.href=image; // it will save locally

Code Example 2

canvas {
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

Learn ReactJs, React Native from akashmittal.com