JSFiddle - React, Tailwind, and code Playground

by Yogesh Rathod

JavaScript

//ES6 Arrow function, lexical this works fine with inner function
'strict mode'
function Person(){
  this.age = 10;

  setInterval(() => {
    this.age++; // |this| properly refers to the person object
   if(this.age < 15)   
     document.write(this.age);  
  }, 1000);
  
}

var p = new Person();