JSFiddle - React, Tailwind, and code Playground

by Alexey Mishin

JavaScript

class ObjMaker {
	constructor(name, obj) {
		this.name = name;
	}
  
  toString() {
  	return this.name;
  }
  
  get itsObjectName() {
  	return this.obj.name
  }
}

const firstObj = new ObjMaker('firstOne');
const secondObj = new ObjMaker('secondOne');

firstObj.obj = secondObj;
secondObj.obj = firstObj;

console.log(`First object. Name: ${firstObj}, args: ${firstObj.itsObjectName}`);
console.log(`Second object. Name: ${secondObj}, args:  ${secondObj.itsObjectName}`);