To fix “ReferenceError:key is not defined” Salesforce Lightning issue, declare the variable inside the for loop. Check the below example.
Sample Code:
Sample Code:
for ( var key in conts ) {
custs.push({value:conts[key], key:key});
}
Cheers!!!