无法在for loop-node.js中实例化多个对象

无法在for loop-node.js中实例化多个对象,node.js,Node.js,我正在使用node.js和n-api。其要点是,我无法在for循环中创建一个新对象,而不会得到一个类型错误,即: TypeError: wrappedExamData.getPatientID is not a function 这仅在第二次尝试创建对象时发生。不过,第一次很好。如果我在for循环之外创建多个新对象,它也可以正常工作 下面是抛出错误的模块 //Require the node module const nodeModule = require('../../../build/R

我正在使用node.js和n-api。其要点是,我无法在for循环中创建一个新对象,而不会得到一个类型错误,即:

TypeError: wrappedExamData.getPatientID is not a function
这仅在第二次尝试创建对象时发生。不过,第一次很好。如果我在for循环之外创建多个新对象,它也可以正常工作

下面是抛出错误的模块

//Require the node module
const nodeModule = require('../../../build/Release/QTWebUI.node');

//Require the Exam Class
const Exam = require('./Exam.js');

exports.retrieveAllExams = function(){
  // Create a js wrapped c++ class to get a list of exam IDs
  var msgGetExamList = new nodeModule.EMGetExamList_Wrapped();
  // Create an array of the examIDs
  var examList = msgGetExamList.getExamIDs();

  console.log(examList);

  var examArray = new Array();

  for(let i = 0; i < examList.length; i++){
    // Create a js wrapped c++ class to send get exam to scanner
    var msgGetExam = new nodeModule.EMGetExam_Wrapped(examList[i]);
    // Get the js wrapped examData from the c++ class
    var wrappedExamData = msgGetExam.getWrappedExamData();
    // Create a new exam object with the wrapped examData
    var exam = new Exam(wrappedExamData);
    // Print the newly created exam object
    console.log("Exam: %s", JSON.stringify(exam)); 
    // Push to array
    examArray.push(exam);
   }

   return examArray;
};
如果我像这样实例化对象:

// Create a js wrapped c++ class to send get exam to scanner
var msgGetExam = new nodeModule.EMGetExam_Wrapped(examList[0]);
// Get the js wrapped examData from the c++ class
var wrappedExamData = msgGetExam.getWrappedExamData();
// Create a new exam object with the wrapped examData
var exam = new Exam(wrappedExamData);
// Print the newly created exam object
console.log("Exam: %s", JSON.stringify(exam)); 
// Push to array
examArray.push(exam);

// Create a js wrapped c++ class to send get exam to scanner
var msgGetExam1 = new nodeModule.EMGetExam_Wrapped(examList[1]);
// Get the js wrapped examData from the c++ class
var wrappedExamData1 = msgGetExam1.getWrappedExamData();
// Create a new exam object with the wrapped examData
var exam1 = new Exam(wrappedExamData1);
// Print the newly created exam object
console.log("Exam: %s", JSON.stringify(exam1)); 
// Push to array
examArray.push(exam1);
它很好用。这里有我遗漏的东西吗

// Create a js wrapped c++ class to send get exam to scanner
var msgGetExam = new nodeModule.EMGetExam_Wrapped(examList[0]);
// Get the js wrapped examData from the c++ class
var wrappedExamData = msgGetExam.getWrappedExamData();
// Create a new exam object with the wrapped examData
var exam = new Exam(wrappedExamData);
// Print the newly created exam object
console.log("Exam: %s", JSON.stringify(exam)); 
// Push to array
examArray.push(exam);

// Create a js wrapped c++ class to send get exam to scanner
var msgGetExam1 = new nodeModule.EMGetExam_Wrapped(examList[1]);
// Get the js wrapped examData from the c++ class
var wrappedExamData1 = msgGetExam1.getWrappedExamData();
// Create a new exam object with the wrapped examData
var exam1 = new Exam(wrappedExamData1);
// Print the newly created exam object
console.log("Exam: %s", JSON.stringify(exam1)); 
// Push to array
examArray.push(exam1);