Array code not accepting methods as replace, slice

48 views Asked by At

I am running a script that reads the files in my project folder and put them into an array.

var fso;
        fso = new ActiveXObject("Scripting.FileSystemObject");
        var objShell = new ActiveXObject("Shell.Application");
        var lib;
        var fitem1 = [];
        var ascFiles = [];
        lib = objShell.NameSpace(oDmApp.ActiveProject.Folder);
        items = lib.Items();
        for (i=0;i<items.Count;i++)
        {
            fitem = items.Item(i);
            fitem1.push(fitem);
        }

After that the code selects the ones with a specific extension.

var ptendsWith = "pt.asc";     
    var ptregx = new RegExp(ptendsWith+"$");
    ptresult = fitem1.filter(function(item){return ptregx.test(item);})  

    var trendsWith = "tr.asc";
    var trregx = new RegExp(trendsWith+"$");
    var trresult = fitem1.filter(function(item){return trregx.test(item);})

After that things start to become strange, i simply cannot manipulate these two arrays generated, trresult and ptresult. A simple command of ptresult[i].slice(0,-2) gives me that the Object doesn't support slice, as if it was not an array. I tested both arrays several times and they are definitively arrays, but I dont understand why I can manipulate them.

Could somenone know what is going on?

0

There are 0 answers