當前位置:生活全書館 >

IT科技

> foreach和map的區別

foreach和map的區別

foreach和map的區別

foreach和map的區別是:

      1、map()會分配記憶體空間儲存新陣列並返回,forEach()不會返回資料。

      2、forEach()允許callback更改原始陣列的元素。map()返回新的陣列。

標籤: map foreach
  • 文章版權屬於文章作者所有,轉載請註明 https://shqsg.com/dianzi/8g4mek.html