javascript canvas clip rectangle

JavaScript
ctx.rect(50, 20, 200, 120); // Create path
ctx.clip(); // Clip, everything outside rectangle is not rendered
Source

Also in JavaScript: