Two JavaScript syntaxes unknown ot me

I had no luck googling both of these. Could someone explain what they are so I can learn more? Thanks
what does syntax like this mean?

  1. I know how to use || (or) in if statements in some languages but what do this mean in what looks like a variable declaration? I took it to mean… what I previously was or a (new) object?
an.compositions = an.compositions || {};
   ...
   ...
};
  1. Is this saying that Object already exists and the property will be the variable or is it saying the Object is being created with its method now?
var comp=AdobeAn.getComposition("029ZXZXZXZT9E");

Thanks for any help :slight_smile:

Colloquially it’s called a default value assignment.

If the an.compositions property already exists then nothing happens, for it’s assigned to be itself.
If however the an.compositions property is falsy, such as when it doesn’t exist or has a false value, it’s assigned to be an empty object instead.

In this case, it’s making sure that if the compositions object doesn’t exist, then it will exist.

It’s saying there exists an object AdobeAn that has a method getComposition(), and the return value of calling that method with the argument "029ZXZXZXZT9E" will be assigned to the variable comp.

@Paul_Wilkins and @m3g4p0p, thanks for taking the time. A lot of “OR” going on in JavaScript these days. I like it, I will try to study this more.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.