How to Iterate Over All the Properties of an Object in JavaScript

const student = {
    first_name: 'Mike',
    last_name: 'Tyson',
    email: 'email@somemail.com'
};

const prop = Object.keys(student);
for (const property of prop) {
    console.log(`${property} : ${student[property]}`);
}



Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *