1# Objects with property names that are not identifiers are not supported 2 3Rule ``arkts-identifiers-as-prop-names`` 4 5**Severity: error** 6 7ArkTS does not support Objects with name properties that are numbers or 8strings. Use classes to access data by property names. Use arrays to access 9data by numeric indices. 10 11 12## TypeScript 13 14 15``` 16 17 var x = {"name": 1, 2: 3} 18 19 console.log(x["name"]) 20 console.log(x[2]) 21 22``` 23 24## ArkTS 25 26 27``` 28 29 class X { 30 public name: number = 0 31 } 32 let x:X = {name: 1} 33 console.log(x.name) 34 35 let y = [1, 2, 3] 36 console.log(y[2]) 37 38 // If you still need a container to store keys of different types, 39 // use Map<Object, some_type>: 40 let z = new Map<Object, number>() 41 z.set("name", 1) 42 z.set(2, 2) 43 console.log(z.get("name")) 44 console.log(z.get(2)) 45 46``` 47 48## See also 49 50- Recipe 002: ``Symbol()`` API is not supported (``arkts-no-symbol``) 51- Recipe 029: Indexed access is not supported for fields (``arkts-no-props-by-index``) 52- Recipe 059: ``delete`` operator is not supported (``arkts-no-delete``) 53- Recipe 060: ``typeof`` operator is allowed only in expression contexts (``arkts-no-type-query``) 54- Recipe 066: ``in`` operator is not supported (``arkts-no-in``) 55- Recipe 144: Usage of standard library is restricted (``arkts-limited-stdlib``) 56 57 58