Skip to main content
Inspiring
November 24, 2021
Answered

Whats going on here.. a bug? variable returns "anonymous"

  • November 24, 2021
  • 2 replies
  • 345 views

I initialize all my action manager id this way. But it fails in one single instance..

When I try to get the ID for "name".

You would expect the code below to alert the same ID, but the first one is correct, the second one alerts "anonymous"

When I save the id to var = name; I get "Adobe Photoshop" returned.

When I save it to var = stringName it is correct. But I'm initializing a ton of ID's this way, why is this one "anonymous"?

 

alert(stringIDToTypeID('name'));

PSString = function() {};
PSString.name = stringIDToTypeID('name');
alert(PSString.name);
This topic has been closed for replies.
Correct answer Kukurykus

Shoudn't it be: PSString = {}

2 replies

Legend
November 24, 2021
quote

When I save the id to var = name; I get "Adobe Photoshop" returned.

 

By @Marvin01

 

name == app.name // global variable

 

activeDocument == app.activeDocument

 

and so on...

Kukurykus
KukurykusCorrect answer
Legend
November 24, 2021

Shoudn't it be: PSString = {}

Marvin01Author
Inspiring
November 25, 2021

Correct, I just copied it from "PSConstants", I thought it should be just an object instead of a function...

Whats going on here is that I actually request the name of the function, since its not named, it returns "anonymous".

I fixed it, and works fine now.