Most likely it's because of the this keyword you have at the beginning.
JavaScript has this thing called scope. It's honestly kind of hard to understand and even harder to explain but the quick and dirty is that the scope is literally exactly what it sounds like: it's the scope of your current piece of code. It tells you what the this keyword will mean.
Take a look at this code from one of the RMMV core files:
Scene_Item.prototype.createCategoryWindow = function() {
this._categoryWindow = new Window_ItemCategory();
this._categoryWindow.setHelpWindow(this._helpWindow);
this._categoryWindow.y = this._helpWindow.height;
this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this));
this._categoryWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._categoryWindow);
};
This is using javaScript's prototype keyword as well, which I won't even begin to try and explain. It suffices to say that we have this object called Scene_Item and it's a function. We are modifying the core components of that function. In JavaScript, functions are objects too and that means they can have properties.
This function is intended to be used with the new keyword, so it's considered a constructor function. You would use it like this:
var MyVar = new Scene_Item();
Once you do that, all of those statements inside the function will run and they are basically creating properties inside of the new instance of that function you made. While we are modifying a specific function that belongs to Scene_Item (the createCategoryWindow() function), the this keyword is directly referencing the Scene_Item object, and more specifically it is referencing the instance of that object. When I created the MyVar variable and assigned it as a "new" Scene_Item, I created an instance of the Scene_Item object, which is what most other languages would call a class.
You could then access one of the properties of your new instance like this:
var test = MyVar._categoryWindow; // Assign the category window object from MyVar to a new variable called test.
As I mentioned, the this keyword refers to the new object that the constructor created. This is one of many ways to construct new objects in JavaScript. It's also one of the messiest and hardest to understand, which is why I generally avoid it.
Outside of the construction of this new object, the this keyword has an entirely different meaning. Once you've created a Scene_Item object, you no longer would use it. If you wanted to change the index property of a Scene_Object's category window, you would need to access that scene object. Using my example, I created a new scene object called MyVar so I would change it like this:
MyVar._categoryWindow.index = 1;
Do you see what I mean? Unless you're actually changing a line of code inside of one of those RMMV core scripts because you do want to change how the constructor works, you would need to access the scene object that was created and probably not using the this keyword.
More Detail
Given no context at all, this will be the same as the window object (the mother of all objects, parent of everything).
console.log(this); // In most browser consoles this will display the window object & all it's details.
When used inside of a function, this will refer to the object that houses that function, like so:
var MyNewObject = {};
MyNewObject.name = "Sam";
MyNewObject.greetings= function(){
console.log("My Name is" + this.name);
};
MyNewObject.greetings(); // prints "My Name is Sam" in the console.
When used in a constructor function with the new keyword, this will refer to the new object that is being created:
var CoolObject = function(nameInput){
this.name = nameInput;
this.greeting = function(){
console.log("My name is " + this.name);
};
};
var MyNewObject = new CoolObject("Sally");
MyNewObject.greeting(); // Logs "My name is Sally"
Because that is a constructor function, those properties do not just inherently exist inside of it. You can't do CoolObject.name, it won't work. The name property is using the this keyword and will only exist when the function is run with the new keyword so that it creates a new object.
Hopefully that helps solve your problem. Unless you were intentionally messing with the prototype constructors, you probably need to find the actual Scene_Object object that you're trying to modify to change its property.