Table of Contents
Creating New Objects using Object Literals
function initObjectsTest() { feli.sayMiaow(); } var feli = { name: 'Felicitas', typ: 'Cat', sayMiaow: function () { logMessageNEW("Miaow !"); } }; Output: 8:28:35:254 Miaow !
- Use Object Literals for Simple Objects
- Objects created via Object Literals are Singelton Objects [ no need to implement a specific design pattern like in Java ]
Creating New Objects using a Constructor Function