JSFiddle - React, Tailwind, and code Playground

HTML

<div id="object-init"></div>
<div id="nested-init"></div>
<div id="nested-method"></div>

JavaScript

function Obj() {
  this.prop = 'val';
  this.init();
}

Obj.prototype = {
  init: function() {
    console.log('object init');
    console.log('prop in object init: ' + this.prop);
    $('#object-init').text('object init');
    this.nested.init();
    this.nested.method();
  }
};

var nested = {
  init: function() {
    console.log('nested init');
    console.log('prop in nested init: ' + this.prop);
    $('#nested-init').text('nested init');
  },
  method: function() {
    console.log('nested method');
    console.log('prop in nested method: ' + this.prop);
    $('#nested-method').text('nested method');
  }
};

$.extend(true, Obj.prototype, nested);

new Obj();