$select.children().remove();
// Add new options to dropdown. Keep a count of options for testing later.
let totalOptions = 0;
- for (const machineName in options) {
- if (options.hasOwnProperty(machineName)) {
- $select.append(
- $(`<option ${machineName === selected ? ' selected="selected"' : ''}></option>`).val(machineName).text(options[machineName]),
- );
- totalOptions++;
- }
- }
+ Object.keys(options || {}).forEach((machineName) => {
+ $select.append(
+ $(`<option ${machineName === selected ? ' selected="selected"' : ''}></option>`).val(machineName).text(options[machineName]),
+ );
+ totalOptions++;
+ });
// Hide the parent options if there are no options for it.
$select.closest('div').toggle(totalOptions > 0).attr('hidden', totalOptions === 0);