As everyone knows, there are loops while, do while and for in javascript. You can make custom loops using other loops. For example, you can get an analogue of the while loop with for.

for(; true; ) { // code } 

We get an endless loop. The question is. Is it possible to make a custom loop, but without built-in loops? I was looking for an answer here and in an English-speaking team, but I was close to the answer.

  • The first option goto (link above) Another option - recursion))) - Vladimir Klykov
  • Only now I wonder what the hell is for you?)) - Air
  • Tsykly seemed to me some strange. Only in them I saw that the arguments were written with ";". It became interesting and how to implement it. After a few minutes of deliberation, I came to such a strange request. - Curious
  • one
    @Flippy so it is foreach =) - Vladimir Klykov

1 answer 1

The javascript language does not allow the programmer to create his own syntax constructs, all possible constructs must be explicitly supported by the language parser. In general, this applies to any language.

However, there are languages ​​in which loops are not a special part of the syntax and can be implemented libraryly. In particular, this includes Lisp-like languages.

  • Useful information, but the only question is how to implement it using everything that gives the language. Fortunately, I have almost implemented it. It remains to modify a little and get rid of bugs. - Curious