const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
const text = ctx.measureText("foo"); // returns TextMetrics object
text.actualBoundingBoxRight; // 15.633333333333333;TextMetrics: actualBoundingBoxRight property / notebook
TextMetrics: actualBoundingBoxRight property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.