Let say there are two select2 elements on the page, both using the 'onChange'. In order to programmatically set a value in one select2 element you use
$('#id1').val('xyz').trigger('change');
If when you make a selection in one of these two elements you want to reset the other to the initial value, the onChange event is triggered by the value setting and the system enters an infinite loop. The same happens if you use
$('#id1').val('xyz').trigger('change.select2')