reformatting string to two string values in javascript
Yes, there are few built-in array functions you may use to simplify your code. I don't think you will ever notice any performance difference but code will also be easier to read:

var id = "HEL-CAS|MAD-STO|XXX-YYY" 

// Format is fixed then it's easy to use a regex
var splittedId = id.split(/[\|-]/);

// Now we can pick "every other element" and then join strings
var from = splittedId.filter(function (v, i) {
    return i &amp; 1 == 0;
}).join('|');

var to = splittedId.filter(function (v, i) {
    return i &amp; 1 == 1;
}).join('|');