Che cosa è una soluzione generale per risolvere Uncaught ReferenceError
.Fix Uncaught ReferenceError
Sto creando una funzione per garantire che il codice di debug entri in produzione. Ma ci possono essere casi in cui una variabile non esiste ma esiste ancora il codice di debug. In tal caso non dovrebbe arrestare il js.
function debug(data, type){
if(type == 'alert' && mode !== 'production'){
alert(data);
}
else if(type == 'halt' && mode !== 'production'){
debugger;
}
else{
console.debug(data);
}
}
debug(xyz) //xyz doesn't exists
'debug (typeof xyz ===" undefined "? Undefined: xyz);' forse? – Ian
Potresti usare un macr ... oh, aspetta. –
Perché si desidera eseguire il codice di debug in produzione? –