JavaScript: Fixed Issues with inheritance