JSFiddle - React, Tailwind, and code Playground

by vinodlouis

JavaScript

class MyPromise{
   
     constructor(fn){
         this.fn = fn
         this._s = null;
         this._e = null;
         this.resolve = this.resolve.bind(this);
         this.then = this.then.bind(this);
      this.fn(this.resolve,this.reeject)   
      
     }
    
    resolve(p){
        console.log(p,'inre solve',this._s);
        this._s(p);
    }
    
    reject(){
        
    }
    
    
    
    then(success,error){
        console.log("ONE",this);
        this._s = success;
        this._e = error;
        
        
    }
 }

var g = new MyPromise((a,b)=>{
 console.log('hello');
 
    a('12');
})

console.log('sdf',g)


g.then((dt)=>{

console.log(dt,'qwe')
},(err)=>{
})