Undocumented functions

I discovered that for the LIST base type in MicroScript 2.0, you can use JavaScript functions from the LIST class.

Here is an example: If you have only objects in the list, and for each object you want to call its method

for item in list
   item.callMe ()
end

But in JavaScript, the LIST class has a forEach method. Which will do the same (with an anonymous function).

list.forEach (function (item) item.callMe () end)

The code can be more readable and without overwhelmingly typing the same thing.

Other functions also work. I tested:

  • forEach - calls the given function for all items in the list
  • every - checks if all elements of the list meet the condition of the anonymous function
  • reduce - allows you to perform operations on all items in the list and print the result
  • find - finds the first element in the list that satisfies the condition of the anoonym function

The STRING class also has many functions in JavaScript.

At the moment, I have only tested the SLICE method - which is not present in MicroScript 2.0.

And it works .

Program code >>> here >>> https://microstudio.dev/i/Loginus/foreach23/