JSFiddle - React, Tailwind, and code Playground

by vor0nwe

JavaScript

var someConfig = {
  things: [
    {
      attr1: 'foo',
      attr2: 'bar',
      action: function() {
        console.log(this.parent);
      }
    }
  ]
}

function Constructor(config) {
  var self = this;
  self.name = 'test';
  self.things = config.things;
  
  $.each(self.things, function(i, thing) {
    thing.parent = self;
    thing.action();
  });
}

var obj = new Constructor(someConfig);
console.log(obj);