// ⭐ draw on <canvas> 2D contextfunctiondrawOnCanvas2D(selector, draw) {let canvas =document.querySelector(selector);if (!canvas) { console.log(`⛔ no such element: "${selector}"`); return; }let context =canvas.getContext("2d");if (draw) draw(context);}// 1st <canvas>drawOnCanvas2D('#square', (ctx) => {ctx.fillStyle ='#f00'; // fill color = redctx.fillRect(0,0,10,10); // fill a square});// 2nd <canvas>drawOnCanvas2D('#circle', (ctx) => {ctx.beginPath(); // new pathctx.arc(5,5,5,0,2*Math.PI,true); // circle to the path ctx.fillStyle ="#00f"; // fill color = bluectx.fill(); // fill path});