LOOPS
Sultan Ahmed
Full Stack Developer | | Proficient in Front-End Development | Specialized in JavaScript TypeScript React.js | Next.js Bootstrap and Tailwind CSS for UI/UX Design.Currently learning at Governor House Sindh
Loops are a fundamental concept in programming and they're used in TypeScript as well. Here are the basic types of loops in TypeScript:
for (let i = 0; i < 5; i++) {
console.log(i); // This will print numbers 0 through 4
}
let i = 0;
while (i < 5) {
console.log(i); // This will print numbers 0 through 4
i++;
}
let i = 0;
do {
console.log(i); // This will print numbers 0 through 4
i++;
} while (i < 5);
let array = [1, 2, 3, 4, 5];
for (let value of array) {
console.log(value); // This will print numbers 1 through 5
}