MZ Java beginner question

Hi, i read some plugins and try to unterstand.
Some Plugins started with:
var Imported = Imported || {};

Can someone explain me?
Imported is a variable. What does the right side?
It means that, if Imported isn't already defined, it'll be defined as an Object 🙂
MZ uses Javascript (different to Java).

The || in that line means 'or'. So it is declaring the variable 'Imported' to be equal to the variable Imported if it is defined. If it is not defined, it uses the 'or' value of a blank Object.
thank you
In case you're interested, here are a couple of links with more details:
  • Logical OR + short-circuit evaluation:
  • Logical operators, like OR, check values based on whether they are "truthy" or "falsy":
Thank you very much. i just wondering, because much Plugins have this start but they dont use it afterwards. So i though it‘s a miracle. But it simply do „nothing“.
Thank you very much. i just wondering, because much Plugins have this start but they dont use it afterwards. So i though it‘s a miracle. But it simply do „nothing“.
imported mostly used in compatibility patch...
for example:
Code:
var Imported = Imported || {};
Imported.MakerA_pluginName= true;
then another plugin maker (let's call it B )... also create some plugins...
and somehow the A and B plugins conflicting each other...
so B decide to create a compatibility patch... but there's a possibility of the plugin user to not having Plugin A installed... so if B just add the patch... there's possibility that the error could occur because of that... so B can add some condition like:
Code:
if (Imported && Imported.MakerA_pluginName){
  //do the compatibility patch here
};
so the plugin will work with or without plugin A installed.

using Imported is actually kinda legacy from previous maker... but nowadays some people did not use imported and just use another variable. since they also need to store some of their own plugin parameter too so why don't they use that variable as the check if their script loaded or not instead of using extra imported variable.

Original thread: https://forums.rpgmakerweb.com/threads/java-beginner-question.128506/