actually, it's not strictly an OOP question... prob is var inside fn inside nested fn returns 'undefined'...
Code:function Employee() { this.manager = "Ravi Gupta"; this.dept = "sales"; this.city = "San Francisco"; this.setVacationDays = function(years) { vacationDays = years * 5; console.log(vacationDays); // ***** prints 'undefined' console.log('years: ' + years); // prints '4' (i.e., this var is fine) }; } var Jon = new Employee(); var JonVacationDays = Jon.setVacationDays(4); console.log(JonVacationDays); // ***** prints 'undefined'
why is var JonVacationDays undefined??
thank you....



Reply With Quote
Bookmarks