Program with try and catch & finally block code example
Example: try-catch-finally
localStorage.getItem(key)
try {
data = JSON.parse(key)
}
catch (e) {
// if the code errors, this bit of code will run
}
finally {
return data
}