0

I'm reading ECMAScript 2023. It say all execution contexts has "Realm" state component.

And it describes,

a realm consists of a set of intrinsic objects, an ECMAScript global environment, all of the ECMAScript code that is loaded within the scope of that global environment, and other associated state and resources.

I understand realm is for global environment like window(browser), global(node). And I understand "Global Environment Records" already define global environment once on first code evaluation.

I wonder why a Realm for a execution context is needed.

I'm reading https://tc39.es/ecma262/#sec-execution-contexts.

Jay
  • 34,438
  • 18
  • 52
  • 81
euijin-kim
  • 21
  • 4
  • 1
    The global environment (record) does **not** contain the "*set of intrinsic objects, all of the ECMAScript code that is loaded within the scope of that global environment, and other associated state and resources*", so that's what the realm is needed for. – Bergi Nov 12 '22 at 16:24
  • 1
    See also [How to understand JS realms?](https://stackoverflow.com/q/49832187/1048572) – Bergi Nov 12 '22 at 17:18
  • Can you clarify how this question relates to MongoDB Realm the database, per the tag on the question? Also, is this a specific programming question? Please review the following two guides on asking questions: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Jay Nov 13 '22 at 14:05
  • @Jay I wanted to ask "ECMAScript realm" but the tag "realm" point out MongoDB Realm. I didn't recognize that. Sorry for that. – euijin-kim Nov 13 '22 at 15:43

1 Answers1

1

You can find the current Realm record as "the value of the Realm component of the running execution context".

That term is referenced multiple times across the specification, mostly for bookkeeping to carry-over the value, but in the end to lookup intrinsic prototypes or cached template strings from the current realm.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375