JSFiddle - React, Tailwind, and code Playground

by Gerald Gillespie

JavaScript

var Obj1 = function(){
	this.name = 'obj1'; 
  
  
};


Obj1.prototype.getName = function(){
	return this.name; 
}; 

Obj1.prototype.doStuffWithName = function( callback ){
	
	return	callback( this.name ); 
}

Obj1.prototype.getWord = function(){
return 'bird'; 
}; 

var registry = {}; 

var Obj2 = function(){
this.name = 'obj2';

this.doStuffWithNames = ( function(t){ 

return t.doStuffWithName(); 
})(this); 

registry[this.name] = this; 
}; 

Obj2.prototype.getName = function(){
return this.name; 
}; 

Obj2.prototype.getWord = function(){
return 'word'; 
}; 



Obj2.prototype.doStuffWithName = function( str){
	//alert(str); 
	//return registry['obj2'].name + str; 
  return this.name + str;  
}

this.name = 'hi';

var myObj1 = new Obj1(); 

var myObj2 = new Obj2(); 

alert( myObj1.doStuffWithName( myObj2.doStuffWithNames ) );