Getting a canvas-context’s last point’s coordinates

I want to create an arrowTo function with CanvasRenderingContext2D.prototype. To do that, I need to get the coordinates of the last point, e.g.

//... 
var ctx = someCanvas.getContext('2d');

ctx.moveTo(10,40);
//the coordinates of the last point are now (10,40)

ctx.lineTo(50,50);
//and now it's (50,50)

//...

How can I retrieve them?

Answer

You’d have to keep track of them yourself. Or do the unthinkable and override moveTo/lineTo to keep track of the last coords via CanvasRenderingContext2D.prototype.