I have this case where I want to run code that may have an error but I don't need to catch it.
If the response is not valid JSON then the result should be 0:
I'd like to use this code:
var overallProgress = try {JSON.parse(text)} ? 0;
Is it possible to the above?
Or something like this:
var overallProgress = try { JSON.parse(text)} catch(error) { 0 };
var overallProgress = try { JSON.parse(text)} catch(error) { overallProgress = 0 };
There are errors using the code above.
I found this related post below but no answer.
Is try {} without catch {} possible in JavaScript?
For anyone whose eyes I've hurt:
var overallProgress = 0;
try { overallProgress = JSON.parse(text).overallProgress }
catch(error) { overallProgress = 0 };