JavaScript: fixed inheritance/overriding issue