1. simple Object Literal var myApp = {}; myApp.panel = {}; myApp.panel.toggleDisplay = function() { this.displayed = (this.displayed==="none")? "" : "none"; } myApp.panel.defaultWidth = 300; myApp.notepad = {}; myApp.notepad.writeable = true; myApp.notepad.font = 'helvetica'; myApp.notepad.setFont = function(theFont) { myApp.notepad.font = theFont; } //OK not inheritance at all. But best we can ..
1. Simple Object Literal myApp.notepad = {}; myApp.notepad.writeable = true; myApp.notepad.font = 'helvetica'; myApp.notepad.setFont = function(theFont) { myApp.notepad.font = theFont; } 2. Nested Object Literal myApp.notepad = { writeable: true, font: 'helvetica', setFont: function(theFont) { this.font = theFont; } } 3, Constructor using Object Literal myApp.Notepad = function(defaultFont) { va..
var whatToBring; switch(weather) { case "Sunny": whatToBring = "Sunscreen and hat"; break; case "Rain": whatToBring ="Umbrella and boots" break; case "Cold": whatToBring = "Scarf and Gloves"; break; default : whatToBring = "Play it by ear"; } ------------------------------------------------ var whatToBring = { "Sunny" : "Sunscreen and hat", "Rain" : "Umbrella and boots", "Cold" : "Scarf and Glov..