for Loops

A JavaScript for loop enables you to execute code a specific number of times by using a for statement that combines three statements in a single block of execution. Here’s the syntax:

for (assignment; condition; update;){  code to be executed;}

The for statement uses the three statements as detailed here when executing the loop:

assignment: This is executed before the loop begins and not again. It is used to initialize variables that will be used in the loop as conditionals.

condition: This expression is evaluated before each iteration of the loop. If the expression evaluates to true, the loop is executed; otherwise, the for loop execution ends.

update: This is executed on each iteration, after the ...

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.