JSFiddle - React, Tailwind, and code Playground

by syncro

JavaScript

function MyObject() {
    this.myProperty = "a property";
    
    console.log("1 - this is %o (%s) in MyObject declaration", this, Object.prototype.toString.call(this));
    (function poll() {
        console.log("2 - this is %o (%s) in poll function", this, Object.prototype.toString.call(this));
        setTimeout(function() {
            console.log("3 - this is %o (%s) in setTimeout function", this, Object.prototype.toString.call(this));
            $.ajax({
                url: "/echo/json/",
                dataType: "json",
                success: function(data) {
                    console.log("4 - this is %o (%s) in ajax.success function. We have some data returned: %o", this, Object.prototype.toString.call(this), data);
                },
                complete: poll
            });
        }, 1000);
    })();
};

$(document).ready(function() {
    var myObject = new MyObject();
});