Undefined

Can someone make a plugin where Undefined does something?
Just so Undefined will have a function and i won't get that error anymore.
@Mooshry From the little amount of JS I've learned so far, Undefined is a JS function that is an error handler, so nothing can be done to turn Undefined into a functioning plugin feature.
Sorry, but that's impossible. If undefined did something or had a function, it would no longer be undefined. So even if you try to overwrite undefined with something, it would still be undefined. Even if it were possible to change undefined, that would be a very, very, very bad idea.

When undefined throws an error, it's because you have a bug. If it stopped throwing errors, you'd still have the bug, but now you don't know where the bug happens.


However, the biggest problem by far is that undefined doesn't always throws errors.
You can for example do:
Code:
if (event) {
    // do something
}

If event is undefined, then the code inside the if branch won't execute. That's because undefined is not truthy (it doesn't evaluate to true).

By adding a function to undefined, it would become an object (one that contains a function) and become truthy. This would break not only a large number of plugins, but might also completely break the RMMV core scripts as well.


TL;DR
Just don't do it.
Oh. I didn't know anything about JS, so i thought undefined was just a thing that was there just chillin', waiting to be a function.

(I can just imagine someone going like: Hey guys! I made undefined a function! And then everyone goes volcanic.)
(I can just imagine someone going like: Hey guys! I made undefined a function! And then everyone goes volcanic.)
Yes, that is correct.

If you want to know more about how it could break things, I was just editing my previous response when you wrote this post.

The bottom line is: you would indeed break a lot of things by defining undefined or even add a function to it.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/undefined.96238/