Refactoring decision tree
var l1 = [...];
var l2 = [...]; 
if (l1.length &gt; l2.length){
    actOnDuplicateOfFirstElementIfPresent(l1, l2, action_a);
} else if (l1.length &lt; l2.length){
    actOnDuplicateOfFirstElementIfPresent(l2, l1, action_b);
} else {
    action_c();
}

function actOnDuplicateOfFirstElementIfPresent(la, lb, action) {
    var i = lb.indexOf(la[0]);
    if (i !== -1){
        action(i);
    }else{
        action_c();
    }
}


This Extract Method refactoring eliminates the duplication found in the first two branches.  Eliminating duplication is both an excellent motivation, and an excellent technique, for refactoring.