try and catch in for loop javascript code example
Example: try catch with for loop in javascript
let object = ['foo', 'bar'], i;
try {
for (i = 0, len = object.length; i <len; i++) {
// do something that throws an exception
}
}
catch (e) {
// handle exception
}