- TypeScript Tutorial
- TypeScript - Home
- TypeScript - Overview
- TypeScript - Environment Setup
- TypeScript - Basic Syntax
- TypeScript - Types
- TypeScript - Variables
- TypeScript - Operators
- TypeScript - Decision Making
- TypeScript - Loops
- TypeScript - Functions
- TypeScript - Numbers
- TypeScript - Strings
- TypeScript - Arrays
- TypeScript - Tuples
- TypeScript - Union
- TypeScript - Interfaces
- TypeScript - Classes
- TypeScript - Objects
- TypeScript - Namespaces
- TypeScript - Modules
- TypeScript - Ambients
- TypeScript Useful Resources
- TypeScript - Quick Guide
- TypeScript - Useful Resources
- TypeScript - Discussion
TypeScript - Array forEach()
forEach() method calls a function for each element in the array.
Syntax
array.forEach(callback[, thisObject]);
Parameter Details
callback − Function to test for each element.
thisObject − Object to use as this when executing callback.
Return Value
Returns created array.
Example
let num = [7, 8, 9]; num.forEach(function (value) { console.log(value); });
On compiling, it will generate the following JavaScript code −
var num = [7, 8, 9]; num.forEach(function (value) { console.log(value); });
Its output is as follows −
7 8 9
typescript_arrays.htm
Advertisements