Post
Topic
Board Meta
Merits 1 from 1 user

Re: Little things that bug you/me about the forum
by
PowerGlove
on 24/01/2025, 19:13:38 UTC
⭐ Merited by vapourminer (1)

However, it would have been great if it could be implemented as a default setting and available without having to do that all the time.
Haha, yeah. You didn't seriously think that I'd expect users to have to do this all the time, did you? Cheesy

At this "concept" stage all I'm really interested in is gathering feedback from the people in this thread that want to try it (for example, I didn't really put much thought into the key assignments; I just quickly roughed out some code to demonstrate what I was thinking about).

Edit: It works! At first, I was getting "undefined", but it worked when I removed the two round brackets "()" before the semicolon at the end. Smiley
That "undefined" is expected, so it probably did work the first time (but you didn't immediately test it, because you got spooked by the scary-looking undefined). When you tried it again (after removing the parentheses you mentioned), you would have gotten something like function in response, which, while more comforting, wouldn't have actually accomplished anything. (In technical terms, initially you entered what's known as an IIFE, that is, an immediately invoked function expression, and on your second attempt you entered just the function expression part, which, besides evaluating to itself, did nothing.)

To confirm the above, try entering this into a console:

Code:
(function () { console.log('!!!'); })();

You should get something like !!! in response (along with an undefined).

Now, try entering the following (that is, make the same bracket-removing adjustment that you made to my code):

Code:
(function () { console.log('!!!'); });

You should get something like function in response (but, notice that you didn't get back any !!!, that is, the function wasn't executed, it was just evaluated).