for in loop key 1

for in loop key

// if you want to get the 'value' of the key  you can do it this way
const user = {firstName: 'John', lastName: 'Doe'}

for(key in user) console.log(user[key]);
// output : 
// John
// Doe

Here is what the above code is Doing:
1. We create an object called user with two keys: firstName and lastName.
2. We create a for…in loop that loops through the keys of the user object.
3. We log the value of each key to the console.

Similar Posts