JSFiddle - React, Tailwind, and code Playground

by titansoftime

HTML

<div id="output"></div>

JavaScript

var a = {

    val: 23,
    
    div: null,
    
    test: function(){
  
        this.div.innerHTML = this.div.innerHTML + ' ' + this.val;
    
    },
    
    run: function(){
        
        // why is "this" the window object here when called by requestAnimationFrame?
        
        requestAnimationFrame(this.run);

        this.test();

    },

    init: function(){
        
      this.div = document.getElementById('output');
        
      this.run();
      
    }
    
};

a.init();