1

While troubleshooting a pdf-lib issue, I'm seeing this, to me unfamiliar, notation:

{ e => e }
  • In the screenshot below I see that what I believe is a property called "dict" of an object called "catalog". The property "dict" is a map data structure.

  • The double bracketed [[Entries]] notation is what I believe signifying a javascript internal property, and I believe may be read as similar to the map.entries() method. Thus, I would expect that what I see below it would be the output of the map entries, the map's key-pair values.

  • Now, this is where things become foggy for me. The key's from this map seem to be numerical values 0-5, and its value are the aforementioned { e => e}. The curly brackets are reminiscent of both objects and functions, and there seems to be an arrow function in there...?

Screenshot:

enter image description here

svenema
  • 1,766
  • 2
  • 23
  • 45

1 Answers1

6

What does/could this Javascript notation { e => e } signify?

It isn't JavaScript notation (e.g., syntax) in that context.¹ The display of objects in a console is not JavaScript syntax, though it's often closely related to it. That {e => e} (and {e => t} later) is just Chrome's console's way of showing you a Map entry where the key is an object whose constructor function is e and whose value is an object whose constructor function is also e (or t for the { e => t } case).

You can see that here (in Chrome or others that use a similar display):

class e {
}
const m = new Map();
m.set(new e(), new e());
console.log(m);
Look in the real JavaScript console.

The real code presumably used a more meaningful constructor names than e and t, but has been minified.


¹ If { e => e} appeared in JavaScript code where a statement was expected, it would be a block with an arrow function inside it that could never be called; if it appeared where an expression rather than a statement was expected, it'd be a syntax error.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875