javascript - Why isn't this anonymous function returning? -
i know complete purposeless code i'm experimenting anonymous functions code have written , had @ hand. can't figure out though why array isn't returning?
(function() { function employee(name, age, pay) { this.name = name; this.age = age; this.pay = pay || 800; } function manager(name, age, pay) { employee.call(this, name, age, pay); this.reports = []; } manager.prototype = object.create(employee.prototype); manager.prototype.addreport = function(report) { this.reports.push(report); } function cashier(name, age, pay) { employee.call(this, name, age, pay); } cashier.prototype = object.create(employee.prototype); var ary = [cashier, manager]; return ary; }());
...why array isn't returning?
it is. you're not doing return value; see ***
comment on first line:
var result = (function() { // **** function employee(name, age, pay) { this.name = name; this.age = age; this.pay = pay || 800; } function manager(name, age, pay) { employee.call(this, name, age, pay); this.reports = []; } manager.prototype = object.create(employee.prototype); manager.prototype.addreport = function(report) { this.reports.push(report); } function cashier(name, age, pay) { employee.call(this, name, age, pay); } cashier.prototype = object.create(employee.prototype); var ary = [cashier, manager]; return ary; }()); console.log(result);
Comments
Post a Comment