Example 1 — Example
Trigger or inspect.
JavaScript
try { const a = new Array(-1); } catch (e) { console.log(e.name); }How It Works
- Run the snippet.
- Inspect the error name.
RangeError — A value is outside the allowed range (invalid array length, bad number).
try { const a = new Array(-1); } catch (e) { console.log(e.name); }Trigger or inspect.
try { const a = new Array(-1); } catch (e) { console.log(e.name); }CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful