notes

`for (; amount--; )`2023. 6. 15.

react-scrollbars-custom예제를 보다가 충격적인 걸 봐갖고

export function renderAmountOfParagraphs(amount = 5, paragraphsProps) {
  const result = [];

  for (; amount--; ) { // ??
    result.push(
      <p {...paragraphsProps} className="ExampleCard-Paragraph" key={`paragraph_${amount}`}>
        {getRandomParagraphText()}
      </p>
    );
  }

  return result;
}
export function renderAmountOfParagraphs(amount = 5, paragraphsProps) {
  const result = [];

  for (; amount--; ) { // ??
    result.push(
      <p {...paragraphsProps} className="ExampleCard-Paragraph" key={`paragraph_${amount}`}>
        {getRandomParagraphText()}
      </p>
    );
  }

  return result;
}

?

  for (; amount--; ) {
  for (; amount--; ) {

?? 🤯

mdn의 for 관련 문서를 보니

All three expressions in the head of the for loop are optional. For example, it is not required to use the initialization block to initialize variables

🤯🤯

이 외에도 충격적인 게 더 있었는데:

Using for without a body

🤯🤯🤯

Using for with two iterating variables

🤯🤯🤯🤯

Tags