December 2017
Beginner
372 pages
10h 32m
English
First, let's look at a simple example of how we can access the elements of an object in an iterative fashion:
let stringArray = "Learning TypeScript";for(let c of stringArray){console.log(stringArray);}
Here, we are looping through each character in a string and printing it. This is possible because the string has a Symbol.iterator property and the for...of loop works on the iteratable objects to print their values. The preceding example can be rewritten by explicitly using the Symbol.iterator property, as shown in the following code snippet:
let stringArray = "Learning TypeScript";let iter = stringArray[Symbol.iterator]();console.log(iter.next().value);
Here, we access the property in a string and then call its ...
Read now
Unlock full access