Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Roses are read, violets are blue. Unexpected token { at line 32.
// inspired by https://twitter.com/nixcraft/status/1162020669242003456
console.log('Roses are red, violets are blue.');
try {
eval('function {');
} catch(e) {
let [_, lineno] = e.stack.match(/:(\d+):(\d+)/);
console.error(`${e.message} at line ${lineno}.`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment