Using:
<input id="selectedRecords" name="selectedRecords" type="hidden" />
Executing this code:
var keyValues = $('#selectedRecords').val().split(",").map(item => item.trim());
console.log('$(#selectedRecords).val(): [' + $('#selectedRecords').val() + ']');
console.log('keyValues: [' + keyValues + ']');
console.log('keyValues.length: [' + keyValues.length + ']');
Gives this console readout (copy pasted from console window in Brave browser):
$(#selectedRecords).val(): []
keyValues: []
keyValues.length: [1]
Why is keyValues.length returning a count of 1 ?