I am learning JavaScript, so today I came across to know that to print or get object properties the for..in loop is used. but i got confuse here because I haven't seen the for..in loop before. so I encountered a query that why we cant use for loop in JavaScript to print the object property? and how does this for..in loop works? here's an example.
let object1 = {
name : 'someone',
name2 : 'someone2',
phno : 234568969
};
and to print this everyone suggests
for(let key in object1)
{
console.log(key + "=" + object1[key]);
}
and my question is how does this loop works, and why this loop for printing the properties.