Q:

syntax error unexpected token

// 1
var printError = function(error, explicit) {
    console.log(`[${explicit ? 'EXPLICIT' : 'INEXPLICIT'}] ${error.name}: ${error.message}`);
}

try {
    // Extra comma in Math.max
    var value = Math.max(1, 2,);
    console.log(value);
} catch (e) {
    if (e instanceof SyntaxError) {
        printError(e, true);
    } else {
        printError(e, false);
    }
}
-1

New to Communities?

Join the community