We all know the basic escaping mechanism in JS:
try {
...
}
catch(err) {
..
}
I have a JSON data in which I want to check if a lead
You could nest your second try/catch block in the exception block of the first try/catch block as follows:
try {
name = lead['Details']['Name']['Full'];
} catch(ex0) {
try {
name = lead['Details']['Name']['First'] + " " + lead['Details']['Name']['Last'];
} catch (ex1) {
name = "No Name";
}
}
This is valid syntax, and functionally equivalent to what you're requiring