JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id="canvas" style="border:solid 1px black;"> </canvas>

JavaScript

var Obj = {
    canvas: {
        context : null,
        init : function() {
            this.canvas = document.getElementById('canvas');
            this.canvas.width = 50;
            this.context = this.canvas.getContext('2d');
            /* ... */
        }
    }
}

Obj.canvas.init();