15
while (max --> min)
{
    console.log(n);
}

I know that --> decreases the value, but where is --> documented in the official documentation?

Braiam
  • 1
  • 11
  • 47
  • 78
diao Yerik
  • 209
  • 2
  • 5

1 Answers1

26

It is the post decrement operator -- followed by the greater than operator >. Just the spacing is weird.

while (max-- > min)

So, while max decremented is larger than min

zerkms
  • 249,484
  • 69
  • 436
  • 539
deceze
  • 510,633
  • 85
  • 743
  • 889
  • 3
    Just a nitpick, wouldn't "`max` decremented is larger than `min`" be better suited for something like `--max > min`? – Aioros Aug 26 '16 at 11:55
  • 1
    @Aioros *"`max`'s value which is decremented afterwards is larger than `min`"* seemed a bit unwieldy. I expect everyone knows how `--` works… :) – deceze Aug 26 '16 at 11:56
  • would this work in for loop like `for( let i = 0; i++ < n; )` – Rahul Yadav Apr 13 '21 at 23:10
  • Check out this CodeWars kata: https://www.codewars.com/kata/6359bf1600fba287b6189f9b/javascript Apparently, "-->" on its own is a valid piece of JS code. – Maksym Shcherban Nov 12 '22 at 21:51
  • P. S. After 5 more minutes of Googling, I now know that due to historical reasons, HTML comments are valid JS code :D – Maksym Shcherban Nov 12 '22 at 21:56