Difference between for in and for of

for in:- this is used to get key and value from the Object.


let employee = {
   "name": "John",
   "salary": 100000,
   "department": "Lead Developer"
}

for(const key in employee) {
   console.log( employee[key]);
}
Output:- John
100000
Lead Developer

for of:- this is used to get the key and value from the Array.


let designation = ["Developer","Sr. Developer","Lead Developer","Team Leader","Project Manager"];
for(const item of designation) {
   console.log(item);
}
Output:-
Developer
Sr. Developer
Lead Developer
Team Leader
Project Manager