MV How to Learn RPG Maker MV JavaScript Framework Better?

How can I learn JS for RM better? I know some of it and created four plugins you can download for free (see my signature.) But I still struggle with this language. JS is such a weird language. I am more comfortable with C++ (which I know relatively little), especially Java and C# (I know these two languages relatively well and have much experience with them.) Here are some issues I run into:

-The language is weird. The RMMV Plugin Manager accepts booleans as only true or false and numbers as numbers, with or without a decimal. But in the plugin, they are treated as strings. At least I know this part and can convert the strings, but other parts of RM JS are weird, and I don't know them.

-I frequently struggle with some things in this RM framework. For instance, I have tried drawing a custom drawing, created a Window class, and instantiated it. I have tried creating my drawIcon() to draw my thing, but it didn't work. However, after struggling and trying out some things, I have made this code that works:

JavaScript:
Windows_Turn_Icon.prototype.drawTurnIcon1 = function () {
    let mySprite = ImageManager.loadSystem('turn_icon_1');
    this.contents = mySprite;
}

I just got lucky that you can initialize the window's contents with an assignment operator (the "=") (because the drawIcon method uses this.contents.blt() method rather than this one). But then there was another problem. I have created a refresh function in this Window class of mine, and I have used "this.contents.clear()," but it just didn't work. I never received an error, either. I needed to clear the icon but nothing. Then, through thinking and experimenting after much struggle, I tried setting the contents null like this "this.contents = null," and it has worked! How can I learn such "weird" parts of this framework (RMMV framework)? Maybe this is more than just luck, but it still isn't easy for me to do so. This was for my newest plugin, Press Turn Battle System for RMMV.

Edit: I've learned a "decent amount" from a tutor. I learn well from a good book or an instructor.
Not to get on your case but...haven't you asked this question before? I dunno, maybe I'm misremembering just part of a conversation.

JS is such a weird language. I am more comfortable with C++ (which I know relatively little), especially Java and C# (I know these two languages relatively well and have much experience with them.)
This is an odd sentiment to me - all of these are C-like languages. Syntax for JavaScript is nearly identical to C++, and very similar to the other two. If you have "much experience" with any of the above, I'd expect it should be easy to understand the others and fill any gaps in your knowledge by reading through the language documentation.

-The language is weird. The RMMV Plugin Manager accepts booleans as only true or false and numbers as numbers, with or without a decimal. But in the plugin, they are treated as strings.
That has nothing to do with JavaScript as a language. It has to do with how the programmers coded the API for plugins.

It's really a pretty straightforward thing to learn. "The @type of a plugin parameter determines what kind of options the user sees in the editor, but it's always a string result." I'm not sure why that would be some big stumbling block or impede your understanding of JavaScript.

It also often doesn't matter. JavaScript's lack of strict class types means you can let the user put a value of 4 into a plugin parameter; it gets interpreted by your plugin parameters field as the string "4"; and you can still just say if ("4" == 4) and it will give you the desired result.

At least I know this part and can convert the strings, but other parts of RM JS are weird, and I don't know them.
...like what? This isn't "RM JS" like RPG Maker has its own special kind of JavaScript. It's just JavaScript...if something doesn't make sense, you can look it up and find the answers.

I have created a refresh function in this Window class of mine, and I have used "this.contents.clear()," but it just didn't work.
Well, did you define a Windows_Turn_Icon.clear() method so that it would do something? I don't see it in your post.

Custom classes don't just magically have methods and properties, you either have to write it for them or you have to make it inherit them from another class. Both C++ and C# have inheritance like this, it shouldn't be a "weird" concept.

That's why if you look at the code for any of the existing window types you'll see their constructors have something like:
Code:
Window_SkillType.prototype = Object.create(Window_Command.prototype);
Window_SkillType.prototype.constructor = Window_SkillType;

So it's inheriting all properties from the Window_Command class, then overwriting specific ones. You can follow that back to Window_Command inheriting from Window_Selectable, which does have a clearItem() method.

But only the Window_Help and Window_Battlelog classes have clear() methods, so unless you inherited from one of those or wrote your own...of course calling it wouldn't do anything.

How can I learn such "weird" parts of this framework (RMMV framework)?
I just don't see what's weird about it. This is a combination of two notions:
1 - just typing words to call as a function doesn't do anything unless you've defined that function with instructions for what to do. First class coding principle.

2 - inheriting methods from other classes, which I should really think you'd be familiar with from the other languages you say you're more comfortable with.

And nothing in there has anything to do with RPG Maker MV. I guess my best suggestions for how to learn this are:
1 - do JavaScript tutorials. I like the w3schools, but there are a number of free online options.

2 - read the existing code and see how things are made. It's all in your js folder.

I don't see any reason any of this should be guesswork.
Oh, I did create a class that inherited from another class. It is the Window_Turn_Icon class. I did the refresh function with this.contents.clear() just like I did in my other plugin but it didn't work. I had to try out something new and what has worked is this.contents = null. So this didn't work:

JavaScript:
Windows_Turn_Icon.prototype.refresh = function(){
    this.contents.clear();
}
It did work on another plugin and this thing didn't return me any errors. But this did work:

JavaScript:
Windows_Turn_Icon.prototype.refresh = function(){
    this.contents = null;
}

Another weird part of JS is using call() and apply() methods, especially like func1.funct2.call(this) and funct1.funct2.apply(this, arguments);

JS is weird that you can set any variable to anything. You can get away with anything. You can get away with murder. Like let i = 5. Then i = "Person".
Oh, I did create a class that inherited from another class. It is the Window_Turn_Icon class.
That doesn't help. There is no existing Window_Turn_Icon class (nor Windows_Turn_Icon, which is what your code says). And you don't show anything that inherits from anything.

So there's still no explanation of why you expected there to be an existing clear() method.

Another weird part of JS is using call() and apply() methods, especially like func1.funct2.call(this) and funct1.funct2.apply(this, arguments);
Okay? So you look up the documentation/tutorials for those two specific things and learn how to use them.

JS is weird that you can set any variable to anything. You can get away with anything. You can get away with murder. Like let i = 5. Then i = "Person".
I agree that's weird coming from a stricter language like C++, but I don't see why it would be confusing or hard to work with. If anything, it makes it easier because you can recycle temporary variables in your code instead of having to declare a new one of the appropriate class.
That doesn't help. There is no existing Window_Turn_Icon class (nor Windows_Turn_Icon, which is what your code says). And you don't show anything that inherits from anything.
This is how I have created this class (and it's correct in the RMMV framework):

JavaScript:
function Windows_Turn_Icon() {
    this.initialize.apply(this, arguments);
}
Windows_Turn_Icon.prototype = Object.create(Window_Base.prototype);
Windows_Turn_Icon.prototype.constructor = Windows_Turn_Icon;

Windows_Turn_Icon.prototype.initialize = function (x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    
}

The contents.clear() method does exist, as it worked on my other plugin and never gave me an error. This is a built-in method to the Windows_Base class from which I inherit the Windows_Turn_Icon().
This is a built-in method to the Windows_Base class from which I inherit the Windows_Turn_Icon().
No - the contents property isn't a Windows_Base Object. It's a Bitmap - the clear() method belongs to that.

I can't immediately know why you calling that method didn't work. Did you do any basic troubleshooting? Use the console to look at a Windows_Turn_Icon Object during play to check its properties?
I did do some troubleshooting but found nothing. But setting that thing to null has worked. I see, since blt is what has the clear() method, the reason why it didn't work because I didn't use blt but just set the contents of the window to the graphic.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-learn-rpg-maker-mv-javascript-framework-better.159086/