Thursday, March 6, 2014

For loops

for loops take a variable and do something whenever that variable is within a certain range, they also always have a loop counter which makes me think that while loops came first

for (i=1; i<=10; i++) { console.log(i); }

1 comment:

  1. Actually, we began with jump instruction in machine code and assembly language. Then early languages like Fortran introduced looping constructs that made looping easier (see the Loops section here: http://en.wikibooks.org/wiki/Fortran/Fortran_control). The Do loop in Fortran is more like the for loop in JavaScript, so I think the while loop came later.

    ReplyDelete