The rules for variable names are:
1 - They must be unique to the scope
2 - They must start with a letter, $ or _
3 - They are case-sensitive - so, y and Y are two different variables
4 - They must not be keywords/reserved words - such as "if", "return", "class" etc
A variable name of either 6 or "6" does not meet those rules.
Additionally, 6 or "6" could easily be misinterpretted.
For example, if we assume that the following runs without errors (which it won't, of course):
let 6 = imgdata;
let "7" = imgdata2;
let a = 6;
let b = "7";
What values do you think a and b will have? 6 and "7", of course NOT imgdata and imgdata2.
And, how would javascript interpret:
let 6 = 7;
let "a" = "b";
? And, if you could do that, how would maths work from then on? You could not use counters or interator variables, for example, because, as soon as they got to 6, the next number would be 8 because 6=7 and 7+1 = 8.
The point here is that letters have meaning within a string but not outside of it, so can be safely used for variable names (within the rules above). Numbers, however, can be either part of a string OR numerics. Thus, 123 and "123" may look the same but are different types of objects - a number and a string - and both are perfectly valid. However, abc and "abc" may also look the same but abc has no meaning unless it has been previously defined as a variable, whereas "abc" is a string - thus, let x = abc will trigger an error if abc has not been defined as a variable, but let x = "abc" is perfectly valid.
You will need to use another means of storing your values or use a valid variable name using the window["xxx" + imgdata.serverid] format (if you still need a dynamic variable name and replacing "xxx" with a prefix of your choice). My suggestion is to use a map - the key being imgdata.serverid and its value being imgdata. That way, you can always retrieve the value using mymap.get(6); Map keys can be strings or numbers, and you can use both within the same map - you just have to remember that mymap.get(6) and mymap.get("6") will point to different map entries. And, you can change the value at any time using mymap.set(6, newvalue).