-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
vm: instanceof test fails when assigning global to vm context #7351
Comments
addaleax
added
vm
Issues and PRs related to the vm subsystem.
v8 engine
Issues and PRs related to the V8 dependency.
labels
Jun 21, 2016
Seems like expected behavior to me. |
Yes, that is expected behavior. You can work around this problem for arrays with |
jasonmit
added a commit
to jasonmit/showdown
that referenced
this issue
Aug 25, 2017
Reason being a.constructor === Array is always falsey when you run showdown within Node's VM API. Related to nodejs/node#7351
tivie
pushed a commit
to showdownjs/showdown
that referenced
this issue
Aug 26, 2017
a.constructor === Array is always falsey when you run showdown within Node's VM API. Related to nodejs/node#7351 Closes #425
A helpful workaround is to use a custom const isInstanceOf = (o, type) => Object.prototype.toString.call(o) === `[object ${type}]`;
isInstanceOf(new RegExp('hello world', 'g'), 'RegExp'); --> true
isInstanceOf(/hello world/ 'RegExp'); --> true
isInstanceOf([] 'Array'); --> true
isInstanceOf(new Error('Error'), 'Error'); --> true |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
When assigning
global
variables to vm context,instanceof
test for the assigned global variables returnfalse
The text was updated successfully, but these errors were encountered: