JavaScript best practice question

Totally JS related. I'm going through codeacademy with this and with functions there's a lot of these(roughly):

Code:
var myFunction = function() {};

I'm wondering what is better(or better practice?) because on another course(same site) it didn't assign any functions to variables. I'm getting a little confused here.
@Sol Marta I moved your question to it's own topic in Learning Javascript, as it seemed the best place for it to me.
When you're making a class, usually you want functions to be available to objects of that class. To do so, you need to assign a function to a class' prototype. For example, to add the example function to every Scene that derives from Scene_Base, we'd add it like so:

Code:
Scene_Base.prototype.example = function(args) {
  console.log("This is an example");
}

Then objects of Scene_Base or derived classes can use the example function. If you just say Scene_Base.example = function() {}, then the function will be static, and will not know anything about any given object. It can only use data that is global, static to that class and others, and any data it creates in the function. You won't be able to do anything with information in a specific object, in this case a specific scene, with a static function.

In newer version of Javascript, they changed how you can define classes so that you don't need to do this manually, but as this is still relatively new technology, RPG Maker MV uses the old method that is compatible with more, older devices in order to increase the potential audience any games may have.
They're trying to illustrate that JavaScript functions are objects. They have properties and methods just like other objects, can be assigned to variables, and can be passed as arguments to other functions.

It's probably too early to think too deeply about this idea. Just remember that functions are another kind of data, like a number or a string, that also happens to be a program.
Thanks. Also I'm not familiar with what a class is as that has not been explained to me quite well yet. I picked up JS today because I figured if I'm seriously going to make something in MV, I would need JS eventually.
You can find more about function declaration vs function expressions here:
https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/
It explains it really good.
Edit: This is turning into an unrewarding, path to no where, definitely not fun, major time sink.
I won't claim to know you feel but I remember how I felt and parts were not fun. I think it helps to have a project in mind. Programming didn't click for me until I started to use what I learned to solve real problems.
Totally JS related. I'm going through codeacademy with this and with functions there's a lot of these(roughly):

Code:
var myFunction = function() {};

I'm wondering what is better(or better practice?) because on another course(same site) it didn't assign any functions to variables. I'm getting a little confused here.
Thanks. Also I'm not familiar with what a class is as that has not been explained to me quite well yet. I picked up JS today because I figured if I'm seriously going to make something in MV, I would need JS eventually.


in fact the term class is not official in javascript.
it comes from java.
this term is used to help distinguish the principle used in java to ascribe a class.
In javascript, the principle of the objectclass, its called prototype

to help you better understand the internal engine of rmmv and node.js.

open the console when game run (F8)
type: window
you will see all variable and fonction allowed and create in the game.

do same thing but add befor new fonction
you will see your new object in the window list.
PHP:
var zzzzzzzmyvar = function(){};
window;

check at the end list you will see you have now acces to your new fonction in the game

Original thread: https://forums.rpgmakerweb.com/threads/javascript-best-practice-question.83402/