How to draw a circle in JavaScript?

To draw a circle in JavaScript, use the canvas element.

For example, if this is your canvas:

<canvas id="canvas" width="400" height="400"></canvas>

Then you can draw a circle with this JavaScript:

const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');

context.arc(canvas.width / 2, canvas.height / 2, 100, 0, 2 * Math.PI, false);
context.lineWidth = 2;
context.strokeStyle = '#000000';
context.stroke();