Cannot read property of 'initialize' of undefined

Please bare with me as I'm still in stage 1 of learning how to create plugins.
Now I wanted to test myself by creating a new window in the equip scene.
I plan to add many contents in this window but for now, I'm testing myself by just displaying the actor's name.
Just that and I'm already having an error at initialization @_@
The error is as the title say and here's my code...
Code:
(function () {
    "use strict";

function Window_MiniDetails() {
    this.initialize.apply(this, arguments);
};

Window_MiniDetails.prototype = Object.create(Window_Base.prototype);
Window_MiniDetails.prototype.constructor = Window_MiniDetails;

Window_MiniDetails.prototype.initialize = function() {
    var lh = Window_Base.prototype.lineHeight()*2;
    Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, lh);
    this._actor = null;
    this.refresh();
};

Window_MiniDetails.prototype.setActor = function(actor) {
    if (this._actor === actor) return;
    this._actor = actor;
    this.refresh();
};

Window_MiniDetails.prototype.refresh = function() {
    this.contents.clear();
    if (!this._actor) return;
    this.drawContents;
};

Window_MiniDetails.prototype.drawContents = function() {
    this.drawActorName(this._actor, this.textPadding(), 0);
};

var SceneEquip_create = Scene_Equip.prototype.create
Scene_Equip.prototype.create = function() {
    SceneEquip_create.call(this);
    this.createMiniDetails();
    this.refreshActor();
};

Scene_Equip.prototype.createMiniDetails = function() {
    this._MiniDetailsWindow = Window_MiniDetails();
    this._MiniDetailsWindow = new Window_MiniDetails();
    this.addWindow(this._MiniDetailsWindow);
};

var SceneEquip_refreshActor = Scene_Equip.prototype.refreshActor;
Scene_Equip.prototype.refreshActor = function() {
    SceneEquip_refreshActor.call(this);
    if (this._MiniDetailsWindow) this._MiniDetailsWindow.setActor(this.actor());
};
 
})();

I've been trying to make this work for the whole day. My mind is already going to explode but I still can't figure out what's wrong @_@
make sure this
function Window_MiniDetails() { this.initialize.apply(this, arguments); };

runs after this
Window_MiniDetails.prototype = Object.create(Window_Base.prototype);
Window_MiniDetails.prototype.constructor = Window_MiniDetails;

the first one is the call, the second one is the definition.
as it is (if that's actually what you have, in that arrangement) the call runs before the definition, ... hence, "undefined."
make sure this


runs after this


the first one is the call, the second one is the definition.
as it is (if that's actually what you have, in that arrangement) the call runs before the definition, ... hence, "undefined."
That makes sense. And probably the problem.
I don't know how to make the definition run first before the call though, what must I do? Even if I put the plugin at the very top or bottom, the error persists.
The order there should be OK: the function does not run when it is defined, only when it is called. This line is important here:
Code:
Window_MiniDetails.prototype.constructor = Window_MiniDetails;
It means "when a new Window_MiniDetails object is created, have it call the Window_MiniDetails function". 😤

I think your error is actually in this line: [Edit: no it wasn't, see following post. xP]
Spoiler: Original post
Code:
var lh = Window_Base.prototype.lineHeight()*2;
Try changing it to this:
Code:
var lh = this.lineHeight() * 2;
Prototypes are made to be instanced and their properties/methods should be called from an instance, e.g. this. Your window inherits from Window_Base, which is why this.lineHeight() is a valid method call. 😮‍💨
I was finally able to fix it. This thread can be closed.
The problem is in this line...
Code:
Scene_Equip.prototype.createMiniDetails = function() {
    this._MiniDetailsWindow = Window_MiniDetails(); //delete this line
    this._MiniDetailsWindow = new Window_MiniDetails();
    this.addWindow(this._MiniDetailsWindow);
};

Original thread: https://forums.rpgmakerweb.com/threads/cannot-read-property-of-initialize-of-undefined.115709/