SES Demo Console
Input:
/** * This example shows two compartments executing the same code with * different globals. They are isolated from each other and from * their parent execution context. */ const x = 0; const c1 = new Compartment({ x: 1 }); const c2 = new Compartment({ x: 2 }); const x1 = c1.evaluate('x'); const x2 = c2.evaluate('x'); /** * This line below will output 3 values to demonstrate that * x has a different value in every context: * - 0 in the start compartment * - 1 in compartment #1 * - 2 in compartment #2 */ ({ x, x1, x2 })
Execute
Clear
Output:
Note: you can look in the console to inspect the original output of the evaluation.