Previous state, current state of 48 digital inputs made whit pcf8574

var Pin=context.get('Pin');
if (Pin===undefined){   // this check cos var Pin=context.get('Pin') || 0; fails for me
    Pin = context.get('Pin');
    var _obj = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
    context.set("Pin", _obj);
}
var obj = context.get("Pin");
var arr= obj.split(",");//Array.from(obj);
       for (var i = 0; i < arr.length; i++) {
          arr[i] = parseInt(arr[i]);
       }

var _byte = msg.payload ^ (1 << 8) - 1; //inputs are High, so flip bit
var pcf8574 = (msg.address-32); //The addresses of the PCF in dec, so we have 0 for the first 1 for...etc.
var state, bit, pinNr;

for (i =0;i<8;i++) { 
    bit = ((_byte & (1 << i)) !== 0) ? 1 : 0; // set bit to 1, if bit !== 0 
    pinNr = (pcf8574*8)+i; //pinNr 0 to 47
        if (arr[pinNr] === bit )
        {
            continue;
        } else 
            msg.payload = pinNr + 1 + "," + bit; //pinNr 1 to 48, High or Low
            arr[pinNr] = bit;
            node.send(msg);
        } 

context.set("Pin", (arr.toString()));

return ;

is the bom, solved all my issues.
In context,flow or global you can set a array, and it will show correctly in the debug window,
But a call back will fail, at least i could't I got Undefined[0]

I needed a system to store the state of 48 inputPins
var Pin=context.get('Pin') || 0;
was failing for me as well, the if (Pin===undefined){ check solved that.

I am sure there are cleaner and better solutions, but for me a Frankenstein coder this is well done I am happy
But still here, need to learn so please don't hold back and shoot at it.