<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript Diff between for..in and for..of</title>
</head>
<body>
<script type="text/javascript">
// Press F12 - View result on Console Panel
var arr = ['a', 'b', 'c'];
Array.prototype.d = true; // prototype to inherit array element
for (var a in arr){
console.log(a); // returns "1", "2", "3", "d"
}
for (var a of arr){
console.log(a); // returns "a", "b", "c"
}
</script>
</body>
</html>