Skip to content

Commit 3c1ad08

Browse files
authored
contents: fix bug in language constructs for iteration
1 parent a94493b commit 3c1ad08

File tree

1 file changed

+2
-2
lines changed
  • questions/what-language-constructs-do-you-use-for-iterating-over-object-properties-and-array-items

1 file changed

+2
-2
lines changed

questions/what-language-constructs-do-you-use-for-iterating-over-object-properties-and-array-items/en-US.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const obj = {
1818
};
1919

2020
for (const key in obj) {
21-
// Optional: to avoid iterating over inherited properties
22-
if (obj.hasOwn(obj, key)) {
21+
// To avoid iterating over inherited properties
22+
if (Object.hasOwn(obj, key)) {
2323
console.log(`${key}: ${obj[key]}`);
2424
}
2525
}

0 commit comments

Comments
 (0)