JSFiddle - React, Tailwind, and code Playground

by Joshua

JavaScript

Function.prototype.branch = function(parent){
	return this.bind(new function(){
		this.parent = parent;
	}(this));
}

var one = function(){
	this.test = 'test';
	var parent = this;

	this.two = {
		three: function(){
			this.four = function(){
				return this.parent.parent.test;
			}.branch(this)
			return this;
		}.branch(this)()
	}
}

var inst = new one();
alert(inst.two.three.four());