Detect Syntax Error

It is not possible to detect JavaScript syntax errors in try...catch, however, you can catch it if you execute code in Function(code)();.

try{
	Function(code)();
}catch(e){
	console.log("Catch syntax errors in code!",e);
}

See Console!

If you want to supress syntax errors of some code, use this formula:

try{Function(code)();}catch{}

If you support IE11, then you need to put "(e)" after catch.

try{Function(code)();}catch(e){}