UNPKG

nic_training

Version:

Sample demos for training on nodejs

23 lines (18 loc) 1.08 kB
//Consumer.js var allOperations = require("./modules"); console.log(allOperations.developedBy);//Read the data console.log(allOperations.developedFor); //creat the object instance here. NOTE: our module is not a self invoking object... var empList = allOperations.Employees();//invoke it here //empList gets the reference of the Employees object... var myList = allOperations.Employees; var javaEmpList = new myList(); console.log(javaEmpList); empList.AddNew({"empID" : 123, "empName":"Phaniraj", "empSalary" : 45000}) empList.AddNew({"empID" : 124, "empName":"Phaniraj", "empSalary" : 45000}) empList.AddNew({"empID" : 125, "empName":"Phaniraj", "empSalary" : 45000}) var list = empList.GetAllEmployees(); for (var i = 0; i < list.length; i++) { console.log(list[i]); } //U could consume any js module only if it exports the object. Any exported object could be either a named object or an anonymous object. U should acquire the reference of the module object by using require method. require uses a . which means that we are including a Custom module.