Author Topic: Can you use .forEach() in Javascript simulations in EA ?  (Read 5726 times)

Rethinking

  • EA Novice
  • *
  • Posts: 14
  • Karma: +1/-0
  • Curious about stuff ... including how to use EA
    • View Profile
    • Rethinking Transport
Can you use .forEach() in Javascript simulations in EA ?
« on: August 23, 2021, 06:22:57 am »
Can you use .forEach() in Javascript simulations in EA ?
Rethinking Transport
- A Transport consultancy with a difference

Rethinking

  • EA Novice
  • *
  • Posts: 14
  • Karma: +1/-0
  • Curious about stuff ... including how to use EA
    • View Profile
    • Rethinking Transport
Re: Can you use .forEach() in Javascript simulations in EA ?
« Reply #1 on: August 23, 2021, 07:26:03 am »
What about Array.length ?

In the following Javascript behaviour, it appears that Array.length is a valid property, but it also appears to always be 1 ??

sim.Array = [];
sim.Array[0] = new sim.CreateObject("Object");
sim.Array[1] = new sim.CreateObject("Object");
sim.Array[2] = new sim.CreateObject("Object");
Trace("Hello");
Trace(Array.length.toString());
sim.Array[Array.length]=new sim.CreateObject("Object");
Trace(Array.length.toString());
sim.Array[Array.length]=new sim.CreateObject("Object");
Trace(Array.length.toString());
Trace("Goodbye");
Rethinking Transport
- A Transport consultancy with a difference