Skip to content
Advertisement

concatenative inheritance two methods with same signature

The code below prints only the event contents, how do I make that print WheatherData.value number? I am coming from java and I am used to do it this way.

JavaScript

Advertisement

Answer

JavaScript

The line above causing the problem. When you assign _event object to { getValue, toString } object you are simply overriding toString method of WeatherData function. Instead, just return { getValue, toString } from your WeatherData function, like below;

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement