Skip to main content
Legend
October 9, 2024

[BUG] Extendscript problem with sort() method

  • October 9, 2024
  • 1 reply
  • 165 views

AE 2024 & Beta crash when using:

alert(
  [2, 1, 0].sort(function () {
    return Math.random() - 0.5
  })
)

 

demo:

(function(thisObj) {
    buildUI(thisObj);
    function buildUI(thisObj) {
        var palette = (thisObj instanceof Panel) ? thisObj : new Window("palette", "BUG", undefined, {
            resizeable: true
        }
                                                                       );
        var button1 = palette.add("button", undefined, "RUN");
        if (palette instanceof Window) {
            palette.show();
        }
        else {
            palette.layout.layout(true);
        }
        button1.onClick = function() {
            alert([2, 1, 0].sort(function () {
                return Math.random() - 0.5;
            }));
        };
    }
}
)(this);

1 reply

Airweb_AEAuthor
Legend
October 9, 2024

 I found just before the crash it returns:

[2,0,0]

which makes no sense.