• Tested code in Emulator

    a = [0,1,2,3,4]
    //=[ 0, 1, 2, 3, 4 ]
    a.length
    //=5
    a.length = 3
    //=3
    a
    =[ 0, 1, 2, 3, 4, length: 3 ]
    // should return >a = [0,1,2]
    

    Tested code in Google Chrome

    a = [0,1,2,3,4]
    //(5) [0, 1, 2, 3, 4]
    a.length
    //5
    a.length = 3
    //3
    a
    //(3) [0, 1, 2]
    

    Workaround in Espruino

    a = [0,1,2,3,4]
    //=[ 0, 1, 2, 3, 4 ]
    a = a.slice(0,3)
    //=[ 0, 1, 2 ]
    a.length
    //=3
    
About

Avatar for MaBe @MaBe started