Write a function that throws an error. Contstraints:
- do not use
throw
- one line only
- simply returning an Error is not sufficient (since it's not thrown)
- function declaration must not throw the error, only execution should throw
- Syntax error is not allowed!
- max. ovarall characters for the code: 15
Tips:
- the function is not something you should ever use in your code
- think of fundamentals and what you learned about them
- it's marked
#beginners
, because it's way easier than you might think - you can make pretty weird things with JavaScript
Top comments (2)
Uuh, love me some code golf!
Shortest implementation of any error I could think of would be something like this:
12 characters.
And then using it like so:
Throws
Cannot read properties of undefined (reading '_')
, though there's no error if the function receives an object as argument with_
defined.Without depending on the input but more lines
Spoiler