Skip to content
Permalink
Browse files

doc: replace const / var with let

PR-URL: #30446
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
duncanhealy authored and MylesBorins committed Nov 12, 2019
1 parent 0f7281a commit 2e70ad391b1df2503e4359f865dc5b86b286ba13
Showing with 8 additions and 3 deletions.
  1. +8 −3 test/parallel/test-vm-function-declaration.js
@@ -28,17 +28,22 @@ const o = vm.createContext({ console });

// Function declaration and expression should both be copied to the
// sandboxed context.
let code = 'var a = function() {};\n';
let code = 'let a = function() {};\n';
code += 'function b(){}\n';
code += 'var c = function() {};\n';
code += 'var d = () => {};\n';
code += 'let e = () => {};\n';

// Grab the global b function as the completion value, to ensure that
// we are getting the global function, and not some other thing
code += '(function(){return this})().b;\n';

const res = vm.runInContext(code, o, 'test');

assert.strictEqual(typeof res, 'function');
assert.strictEqual(res.name, 'b');
assert.strictEqual(typeof o.a, 'function');
assert.strictEqual(typeof o.a, 'undefined');
assert.strictEqual(typeof o.b, 'function');
assert.strictEqual(typeof o.c, 'function');
assert.strictEqual(typeof o.d, 'function');
assert.strictEqual(typeof o.e, 'undefined');
assert.strictEqual(res, o.b);

0 comments on commit 2e70ad3

Please sign in to comment.
You can’t perform that action at this time.