
objects in JavaScript
🧠 Objects in JavaScript — A Simple and Complete Guide After understanding functions as workers , the next important concept is objects . If functions are workers, then: Objects are like real-world things that store data and behavior together. 🌱 What is an Object? (First Principle) An object is like a person or thing that has: properties (data) actions (functions) 🧒 Real-Life Analogy Think of a tea shop owner : Name → Arun Age → 25 Job → Making tea And he can: make tea take orders 👉 That is exactly what an object is. ⚙️ Basic Definition An object is a collection of key-value pairs , where values can be data or functions. ☕ Simple Example ```javascript id="k0f8kp" const teaShop = { owner: "Arun", location: "Erode", makeTea: function() { console.log("Tea is ready"); } }; --- 👉 Here: * `owner`, `location` → properties * `makeTea` → function (method) --- # 📦 Accessing Object Data ```javascript id="3zv2n5" console.log(teaShop.owner); // Arun teaShop.makeTea(); // Tea is ready 🧠 Objects + Fun
Continue reading on Dev.to
Opens in a new tab



