我之前尝试过在构造函数之后移动数组。我很确定此时我的语法错误,我已经尝试研究了很长一段时间但没有运气。任何帮助,将不胜感激。
class dataService {
constructor() {
}
//I need to be able to initialize this array of objects and create an empty constructor which does nothing
var data = [ // Error: Construcotr, method, accessor, or property was expected
name1 = { name: "Mitchell", gender: "male", address: "201 Burns Street East", age: 20, phoneNumber: "905-550-7379" },
name2 = { name: "Bob", gender: "male", address: "555 Hello Street", age: 25, phoneNumber: "123-456-7891" },
name3 = { name: "Gillian", gender: "female", address: "457 Baker Street", age: 23, phoneNumber: "555-111-999" }
];
getData(numRecords) {
numRecords = numRecords || undefined;
if (numRecords == undefined) {
return data;
}
};
}
Helenr
相关分类