We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, is this the expected behaviour?
Was expecting test_data.test_array instanceof Array to return true
test_data.test_array instanceof Array
true
const vm = require('vm'); const test_data = new vm.Script(` test_data = { test_array: [] }; `).runInNewContext(); console.log(JSON.stringify({ test_data }, null, 2)); // { // "test_data": { // "test_array": [] // } // } console.log(typeof test_data.test_array); // object console.log(test_data.test_array instanceof Array); // false, should be true
The text was updated successfully, but these errors were encountered:
runInNewContext() means that the Array in the new context is different from the Array in the calling context so this behavior is expected. It's similar to the way instanceof doesn't work as you might expect when using data in iframes in the browser.
runInNewContext()
Array
instanceof
Sorry, something went wrong.
I'm going to close but there's more info at nodejs/node-v0.x-archive#1277 including a note that Array.isArray() is probably what you want to use.
Array.isArray()
That makes sense lol, should've googled more. Thanks a lot @Trott!
No branches or pull requests
Hi, is this the expected behaviour?
Was expecting
test_data.test_array instanceof Array
to returntrue
The text was updated successfully, but these errors were encountered: