Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript for

for (let i = 0; i < 3; i++) {
  console.log ("Block statement execution no." + i);
}

// *******************

let arr = [10, 20, 30, 40];

for (var val of arr) {
  console.log(val); // prints values: 10, 20, 30, 40
}

// *******************

let str = "Hello World";

for (var char of str) {
  console.log(char); // prints chars: H e l l o  W o r l d
}

// *******************

for (var index in arr) {
  console.log(index); // prints indexes: 0, 1, 2, 3

  console.log(arr[index]); // prints elements: 10, 20, 30, 40
}

// *******************
let arr = [10, 20, 30, 40];

for (var index1 in arr) {
  console.log(index1); // prints indexes: 0, 1, 2, 3
}
console.log(index1); //OK, prints 3

// *******************

for (let index2 in arr) {
  console.log(index2); // prints elements: 0, 1, 2, 3
}
console.log(index2); //Compiler Error: Cannot find index2
Comment

PREVIOUS NEXT
Code Example
Typescript :: typescript algorithm to find repeating number sequences over time 
Typescript :: display current directory contents in a long format with user and group ids displayed numerically 
Typescript :: React Typescript form event 
Typescript :: foreach loop in typescript 
Typescript :: use map with filter in react components from arrays of data 
Typescript :: get all the game objects in a scene unity 
Typescript :: react link state 
Typescript :: adjust distance of subplots in python 
Typescript :: typescript window ethereum 
Typescript :: check if document exists mongodb python 
Typescript :: angular get url params 
Typescript :: getstaticpaths in nextjs 
Typescript :: passing data to a MatDialog component using inject 
Typescript :: typescript bigint vs number 
Typescript :: docx to pdf javascript 
Typescript :: methods defined as testmethod do not support web service callouts 
Typescript :: how to check if elements dont exist in testing library 
Typescript :: pandas value_counts sort descending 
Typescript :: filter array of objects react 
Typescript :: convert list to list of lists on every n elements python 
Typescript :: dynamic subplots matplotlib 
Typescript :: Accessing Java Array Elements using for Loop 
Typescript :: python requests no follow redirect 
Typescript :: typescript typecast 
Typescript :: flutter google fonts 
Typescript :: typescript get the time moment 
Typescript :: angular rxjs mergemap 
Typescript :: navigate in new tab with query params angular 
Typescript :: promise allsettled typescript 
Typescript :: loop through imports python 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =