JSFiddle - React, Tailwind, and code Playground
HTML
<div>Wait for it...</div>
JavaScript
Function.prototype.delay = function(ms) {
var fn = this;
return function() {
setTimeout(fn, ms);
};
};
function sayHello() {
var hello = document.createElement("div");
hello.textContent = "Hello!";
document.body.appendChild(hello);
}
var sayHelloDelayed = sayHello.delay(1000);
sayHelloDelayed();