From dac5f58205d1e64e824b89f408169ad1483109c3 Mon Sep 17 00:00:00 2001 From: Sepand <31024588+DSep@users.noreply.github.com> Date: Tue, 6 Nov 2018 14:22:57 -0800 Subject: [PATCH] Added Info About ForEach() Method (#34133) Added a section on the very commonly used forEach() method for arrays. Also improved sentence structure of previous sentences. --- guide/english/typescript/array-type/index.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/guide/english/typescript/array-type/index.md b/guide/english/typescript/array-type/index.md index 47b3e21550..c3b3bbf677 100644 --- a/guide/english/typescript/array-type/index.md +++ b/guide/english/typescript/array-type/index.md @@ -21,7 +21,7 @@ let names: Array = ['Javier', 'Emma', 'John', 'Sophia', 'Emma']; ## Built-in methods In Typescript's Array type you can use some built-in functions. Each type has common and unique methods. -Below you can read about the most used ones of the array type's methods. In the example, we will use the array declaration from above. +Below you can read about the most used methods of the Array type. In the example, we will use the array declaration from above. ### pop() Removes the last element from an array and returns with it. @@ -50,4 +50,15 @@ var reverseNames = names.reverse(); //reverseNames = ['Emma','Sophia','John','Emma','Javier'] ``` +### forEach() +Perform a designated task for every item in the array +```typescript +var exclamationPointNames = names.forEach(doSomething); +//doSomething = function (name: string, index: number) { +// name[i] = name[i] + "!"; +//} +//exclamationPointNames = ['Emma!','Sophia!','John!','Emma!','Javier!'] +``` + + [More methods and description at TutorialsPoint](https://www.tutorialspoint.com/typescript/typescript_arrays.htm)