I do not understand the code version of time based sprite animation?

I’m Universo and for the longest time had coding issues around the concept of time-based sprite animation basically, do not know how to implement it and any code or explanation simple or complex that I’ve found has been extremely confusing to me and was hoping to have a kind person walk me through the code step by step, explaining exactly how this is implemented correctly.

Here’s what, I believe to know about the concept and or idea for time-based sprite animation it is to construct a delay or halt of some code statement using time of some kind in milliseconds with a collection of moving images and or sprites however any attempts from the tutorial’s or my own brain have resulted in inaccurate various speed sprite animations and not the consistent stable speed, Id appreciate and be grateful for here’s some code to show my progress and perhaps help you understand my position in this mess baring in mind, I prefer my code be as extremely simple and speedy as possible within the limitations, of course:

JavaScript with HTML5 Canvas

window.onload = function () {      var canvas = document.getElementById("canvas");      var ctx = canvas.getContext("2d");      var FrameSize = 120; //120 pixels     var FrameNumber = 0; //obvious     var img = new Image();     img.src = 'sprite_ani.png';     var last = 0; // no idea         function Render() {        ctx.clearRect(0,0 ,640,480);       now = performance.now();       delta = now - last; // last is 0, how does this work?       last = now; // last is now, why?        if(delta > 20 //what does this value represent) {          FrameNumber += FrameNumber + 1;          delta = 20;       }                 if(FrameNumber>=4){               FrameNumber = 0;       }          ctx.drawImage(img,FrameSize*FrameNumber,0,120,120,0,0,120,120);          window.requestAnimationFrame(Render);     }     window.requestAnimationFrame(Render);    }     

As you can see, it’s extremely simple yet, I’m still struggling to not only understand it but extremely simply implement it, I’m not a fan of over-complicated coding hence why I ditched c++ ages ago.

Could someone in extremely simple english guide me through time-based sprite animation in the context of JavaScript preferably, Id also really appreciate various time-based sprite animation methods being explained too in extremely simple terms but not holding out, I thank you for reading this far.