Я пытаюсь впервые ввести утку в java-скрипте, чтобы избежать длительных условных выражений. Ниже моя утка набрав код
// A simple array where we keep track of things that are filed.
filed = [];
function fileIt(thing) {
// Dynamically call the file method of whatever
// `thing` was passed in.
thing.file();
// Mark as filed
filed.push(thing);
}
function AuditForm(reportType) {
this.reportType = reportType;
}
AuditForm.prototype.file = function () {
console.log("Hello from Here!!!");
//Call Ajax here and then populate grid
}
var AuditForm = new AuditForm("AuditForm");
и вот как я это называю
fileIt("AuditForm");
с приведенным выше кодом, я могу нажать на fileIt (вещь) функция, но получить неизвестную ошибку на thing.file();
Что здесь не так ... Пожалуйста, предложите.