1# ``for .. in`` is not supported 2 3Rule ``arkts-no-for-in`` 4 5**Severity: error** 6 7ArkTS does not support the iteration over object contents by the 8``for .. in`` loop. For objects, iteration over properties at runtime is 9considered redundant because object layout is known at compile time, and 10cannot change at runtime. For arrays, iterate with the regular ``for`` loop. 11 12 13## TypeScript 14 15 16``` 17 18 let a: number[] = [1.0, 2.0, 3.0] 19 for (let i in a) { 20 console.log(a[i]) 21 } 22 23``` 24 25## ArkTS 26 27 28``` 29 30 let a: number[] = [1.0, 2.0, 3.0] 31 for (let i = 0; i < a.length; ++i) { 32 console.log(a[i]) 33 } 34 35``` 36 37## See also 38 39- Recipe 082: ``for-of`` is supported only for arrays, strings, sets, maps and classes derived from them (``arkts-for-of-str-arr``) 40 41 42