I am very new to Javascript and have looked at someone elses code to try and work out what it does. I have seen the following, and can't understand why 'total' has been set twice using different notation. Am I being really dense here? The code is:
contents = {
apples : 0,
oranges : 0,
bananas : 0,
grapes : 0,
peach : 0,
total : function() {return this.apples+this.oranges+this.bananas+this.grapes+this.peach;}
};
contents.total = function() {return this.apples+this.oranges+this.bananas+this.grapes+this.peach;};
I know that contents.total is outside of making the object, but why set the property immediately after if it's already set to the same thing?