I have two module with very similar methods (it is a part of an adapter pattern that implements the same methods/interface). The differences are in two lines of code:
function MyModuleA{
}
ModuleA.prototype.myMethod = function{
--LineA--
--LineB--
--LineC--
--LineD--
}
function MyModuleB{
}
ModuleB.prototype.myMethod = function{
--LineA--
**--LineE--** //different line
--LineB--
--LineC--
**--LineF--** //different line
--LineD--
}
Can I use javascript inheritance to implement the similar lines only once?
Thanks!!
if
statements around the dissimilar code to only run it under the ModuleB. – Giscard Biamby Sep 21 '12 at 21:23