JavaScript Object Methods: keys, values, entries

🧠 Day 23 — JavaScript Object Methods (keys, values, entries) Working with objects? These methods make life much easier 🚀 --- ⚡ 1. Object.keys() 👉 Returns all keys of an object const user = { name: "John", age: 25 }; console.log(Object.keys(user)); // ["name", "age"] --- ⚡ 2. Object.values() 👉 Returns all values console.log(Object.values(user)); // ["John", 25] --- ⚡ 3. Object.entries() 👉 Returns key-value pairs as arrays console.log(Object.entries(user)); // [["name", "John"], ["age", 25]] --- 🧠 Looping Example for (let [key, value] of Object.entries(user)) { console.log(key, value); } --- 🚀 Why it matters ✔ Easy iteration over objects ✔ Cleaner code ✔ Useful in real-world data handling --- 💡 One-line takeaway: 👉 “Use keys, values, entries to work with objects easily.” --- Once you master these, handling objects becomes much smoother. #JavaScript #Objects #WebDevelopment #Frontend #100DaysOfCode 🚀

To view or add a comment, sign in

Explore content categories