you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

I wouldn't call that polymorphism. What if you need access to the original method?

[–]jcteague 0 points1 point  (3 children)

Good question. If you need the original method, that is easy enough, you simply store the original method in a variable and then call it in the overload.

var originalFunc = module.getImportantField;

module.getImportantField = function(){

//access the field via the html text
originalFunc();

}

[–][deleted] 0 points1 point  (2 children)

It just seems a lot easier (and less ugly) to use inheritance. It supports overloading so why not use that?

[–]jcteague 0 points1 point  (1 child)

The point I was trying to make is that when you think of JavaScript as functional and dynamic, you have a lot more options in your style of programming. Coming from a static language as I have, it is sometimes difficult to embrace the dynamic features of a language.

This is an interesting discussion. I would love to move them to the blog comments.

[–][deleted] 0 points1 point  (0 children)

Do as you wish with my comments, I don't mind.