Skip to content

Instantly share code, notes, and snippets.

@AnnaMag
Created January 14, 2017 17:23
Show Gist options
  • Save AnnaMag/12ee15774ca1f3b093f36ea27047621a to your computer and use it in GitHub Desktop.
Save AnnaMag/12ee15774ca1f3b093f36ea27047621a to your computer and use it in GitHub Desktop.
'use strict';
require('../common');
var assert = require('assert');
var vm = require('vm');
var Parent = Object.create(null);
Parent.prototype = {
sProp: 'some string value',
numProp: 2,
bProp: false
};
var child = Object.create(Parent.prototype, {
color: { writable: true, value: 'red' },
desc: {
configurable: true,
get: function () { return "get working"; },
set: function (value) { this.color = value; }
}
});
const context = vm.createContext(child);
const code = `Object.getOwnPropertyDescriptor(this, "bProp");
this.desc;
`;
const codee = `
`;
const res = vm.runInContext(code, context);
console.log(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment