Javascript typeScript中的循环替换

Javascript typeScript中的循环替换,javascript,Javascript,在Java中,我们有一个流类,它在替换循环中起着重要的作用 例如: List<Integer> number = Arrays.asList(2,3,4,5); // demonstration of map method List<Integer> square = number.stream().map(x -> x*x). collect(Collectors.toList())

在Java中,我们有一个流类,它在替换循环中起着重要的作用

例如:

List<Integer> number = Arrays.asList(2,3,4,5); 
  
    // demonstration of map method 
    List<Integer> square = number.stream().map(x -> x*x). 
                           collect(Collectors.toList()); 
上面的代码也可以使用while&for循环编写,但我们更喜欢使用Stream类来处理对象集合

我们在typeScript中是否有相同的流类型的替代方案,以及我不想在typeScript中的任何迭代工作中使用循环


谢谢。

您可以在typescript上使用javascript数组

让数:数[]=[2,3,4,5] 设平方:number[]=number.mapx=>x*x
您还可以在

上学习javascript数组,无法理解downvote的原因。请提供具体的解决方案或一些参考。链接似乎helpful@Shivanshu您还可以标记为已解决和/或向上投票