diff --git a/lib/vm.js b/lib/vm.js index 1fdea8433495b2..b48e79c282541b 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -235,14 +235,12 @@ function createContext(contextObject = {}, options = kEmptyObject) { validateBoolean(wasm, 'options.codeGeneration.wasm'); } - let microtaskQueue = null; - if (microtaskMode !== undefined) { - validateOneOf(microtaskMode, 'options.microtaskMode', - ['afterEvaluate', undefined]); - - if (microtaskMode === 'afterEvaluate') - microtaskQueue = new MicrotaskQueue(); - } + validateOneOf(microtaskMode, + 'options.microtaskMode', + ['afterEvaluate', undefined]); + const microtaskQueue = microtaskMode === 'afterEvaluate' ? + new MicrotaskQueue() : + null; makeContext(contextObject, name, origin, strings, wasm, microtaskQueue); return contextObject;