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

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

7
  • it's two things ... post decrement -- and a greater than comparison > Commented Aug 26, 2016 at 10:00
  • 2
    --> is -- followed by >, two operators... So max-- > min if you prefer. Commented Aug 26, 2016 at 10:01
  • 4
    Somebody either slipped on the keyboard or they thought they were being clever… Commented Aug 26, 2016 at 10:03
  • 8
    @judgeja Any cleverness that spawns a question on SO because the reader goes "WTF?!" is bad cleverness… Commented Aug 26, 2016 at 10:07
  • 13
    see also this highly upvoted question (currently the 8th highest upvoted question overall) Commented Aug 26, 2016 at 10:54

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

5 Comments

Just a nitpick, wouldn't "max decremented is larger than min" be better suited for something like --max > min?
@Aioros "max's value which is decremented afterwards is larger than min" seemed a bit unwieldy. I expect everyone knows how -- works… :)
would this work in for loop like for( let i = 0; i++ < n; )
Check out this CodeWars kata: codewars.com/kata/6359bf1600fba287b6189f9b/javascript Apparently, "-->" on its own is a valid piece of JS code.
P. S. After 5 more minutes of Googling, I now know that due to historical reasons, HTML comments are valid JS code :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.