The meaning of this code

Hi to all,
I am relatively new to JS programming, so my question is what the next code means:

(a = new function()).function(arg1, arg2, arg3)

First function is enclosed in parentheses and after dot there is another function.
Is it related to a self-invoking function thing?

Please explain it to details if you will,

This isn’t valid JS code, it’s gibberish.

For example:

sitID = stringIDToTypeID; //defined before the next code:
(acDs= new ActionDescriptor()).putEnumerated(sitID(‘using’), sitID(‘fillContents’), sitID(‘pattern’));

It’s a Adobe’s PS code

I’ve never met such code in my experience, but it definitely exists. So I think it’s not gibberish.

It’s an extremely bad way of invoking an object and immediately calling one of that object’s methods.
It relies on Javascript’s return from an assignment operation being the object that was assigned.

(And to blunt the inevitable follow up of ‘why is it bad’, my response is ‘why did you need to ask a web forum what the code actually was?’)


Thank you for your answer

I didn’t think someone will be hurt that I asked. :upside_down_face:
My curiosity has many different approaches in the means of learning, maybe strange, but that’s me.

Nono, it’s not that someone was hurt that you asked, the point was that the code as written has such poor readability that you HAD to ask, which makes it (IMO, at least), bad code.

Sorry then, my misunderstanding. :slight_smile:

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