📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
- Using Object.keys
- Using Object.values
- Using Object.getOwnPropertyNames
Check out all JavaScript examples at https://www.javaguides.net/p/javascript-tutorial-with-examples.html
1. Using Object.keys
var user = {
firstName: 'Ramesh',
lastName: 'Fadatare',
emailId: 'ramesh@gmail.com',
age: 29
}
console.log(Object.keys(user).length);
4
2. Using Object.values
var user = {
firstName: 'Ramesh',
lastName: 'Fadatare',
emailId: 'ramesh@gmail.com',
age: 29
}
console.log(Object.values(user).length); // size is 4
4
3. Using Object.getOwnPropertyNames
var user = {
firstName: 'Ramesh',
lastName: 'Fadatare',
emailId: 'ramesh@gmail.com',
age: 29
}
console.log(Object.getOwnPropertyNames(user).length);
4
Comments
Post a Comment
Leave Comment