Answer the question
In order to leave comments, you need to log in
Why are const \ let variable not available from the sandbox?
const vm = require('vm');
const context = {};
const code = `
const v1 = 5;
const v2 = 8;
var c1 = 4;
var c2 = 5;
`;
vm.runInNewContext(code, context);
console.dir(context)
const code = `
{const v1 = 5;
const v2 = 8;}
var c1 = 4;
var c2 = 5;
`;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question