Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript: Function Chaining
    primarykey
    data
    text
    <p><em><strong>solution: nope. you can't do it. chain commands with &amp;&amp; and be done with it.</em></strong></p> <p><strong>tl;dr: in <code>random.function("blah").check()</code>, how do I make it ignore <code>check()</code> if <code>function("blah")</code> returns false? Or is this even possible?</strong></p> <p>The background:</p> <p>Okay, so I'm horrid at code. But I'm trying to procrastinate by coding things that would make my life marginally easier. And my marginally, I mean microscopically. So basically, my entire project is based around objects and plugins. (plugins being additional .js files that contain an object. for example, afk.js looks something like this:</p> <pre><code>global.afk = function(){}; afk.check = function(){ ... }; </code></pre> <p>etc, etc. And by loading that js file, I get access to the afk object and all the function therein. Probably not efficient, but it works and it makes figuring out what functions are doing what easier. </p> <p>Back to the procrastination bit. Because I don't know what plugins are loaded, in some of the shared core .js files, there are these conditional statements: <code>if (plugin.has("afk")) { afk.check(); };</code> However, I got bored and made <code>plugin.has()</code> return the actual object instead of 'true', so I could do:</p> <pre><code>plugin.has("afk").check(); </code></pre> <p>which works as expected. Unless there is no afk plugin, which throws the obvious error of "false has no method check".</p> <p>So that's that. Any ideas? Also, if you have any qualms with anything, let me know. I know I do a lot of things wrong/inefficiently, and it's nice to fix them when I figure it out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload