1

If I see in the FOR loop condition:

let i = 0, chr

like here:

enter image description here

from here: String.prototype.charAt()

what does the second part (chr) of initialExpression mean?

kokserek
  • 530
  • 8
  • 21
  • 1
    it is a declaration of `chr`. it looks like it is use inside of the loop for a character. – Nina Scholz Mar 11 '20 at 11:07
  • 1
    It creates a variable `chr`, same as `i`. This is effectively a use of the comma operator, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator – CBroe Mar 11 '20 at 11:08
  • 1
    It's just declaring two variables. It works the same way outside the loop header. – Felix Kling Mar 11 '20 at 11:09
  • ahha I got it tnx – kokserek Mar 11 '20 at 11:09
  • 3
    @CBroe: This is not the comma operator, it's part of the syntax of variable declarations. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var – Felix Kling Mar 11 '20 at 11:09

0 Answers0