How do I find an array item with TypeScript? (a modern, easier way)

前端 未结 5 728
长发绾君心
长发绾君心 2020-11-28 09:49

Is there a canonical way to find an item in an array with TypeScript?

ES6+ allows this simple/clean approach

[{"id":1}, {"id":-2}         


        
5条回答
  •  自闭症患者
    2020-11-28 10:12

    For some projects it's easier to set your target to es6 in your tsconfig.json.

    {
      "compilerOptions": {
        "target": "es6",
        ...
    

提交回复
热议问题