Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

Arrays with Sahi OS

Hello all,

I'm having a lot of trouble working with arrays in sahi. In vanilla JS, I can use things like pop() and array.forEach to do all sorts of useful things with arrays. Is it possible to use things like that in sahi? I tried using _call and _eval to run JS through the sahi controller without much luck, and I couldn't find anything in the api that seems to do things like that with normal sahi code.

Thanks!

Comments

  • SitaSita Members
    Hi DeviSanFran,

    Yes, you can perform all required actions with arrays using Sahi. Sahi script is based on javascript. So you can directly use the looping conditions for the arrays.

    For example:

    var $arr=[10,20,30];
    $arr=$arr.pop();
    _log($arr);
    //will perform the pop operation on the array and returns the last element from the array.

    Similarly, you can also loop through the array as below.

    var $arr=[10,20,30];
    for(var $i=0;$i<$arr.length;$i++){
    _log($arr[$i]);
    }

    You can use the _call or _eval API for any expression which needs to be evaluated on the browser DOM.

    Hope this helps!

    Thanks and regards,
    Sita
Sign In or Register to comment.