How do you source the data of multiple objects from a text file in JavaScript? I'm creating a program that will work with employee data and each employee will be treated as an object; I want the object data to come from an external source (i.e. a text file or an Excel spreadsheet), instead of having to explicitly write out the data for each employee within the code of the program. The multiple employee objects will be pushed into an array and then I'll interact with them in various ways. In the code below, I've had to explicitly write out employee data (see below). I want to source that data from some external source instead. Thanks!
function Employee (name, roomID, email)
{
this.name = name;
this.roomID = roomID;
this.email = email;
}
function EList()
{
this.employees = [];
this.firstindex = 0;
}
var employeeList = new EList();
var employee1 = new Employee("Aman Mundra", "D3-1", "aman.s.mundra@gmail.com"); //parameters inside parenthesis
var employee2 = new Employee("John Doe", "D4-1", "john.doe@gmail.com");
var employee3 = new Employee("Jane Doe", "D4-2", "jane.doe@gmail.com");
employeeList.employees.push(employee1, employee2, employee3)