The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Google ad representative line

Last post 04-23-2008 5:57 PM by Volmarias. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 04-23-2008 1:15 PM

    Google ad representative line

    We were having problems on our site where ad positions would swap content. We still haven't figured out the problem but I did find this while digging through some of Google's JavaScript: 

    function st(a) {
     return true;
    }

    Filed under: , , ,
  • 04-23-2008 1:25 PM In reply to

    • Snarf
    • Not Ranked
    • Joined on 04-17-2008
    • Posts 3

    Re: Google ad representative line

    I hope they didn't forget the other Boolean functions.

    function sf(a) {
     return false;
    }

    function sfnf(a) {
      return FILE_NOT_FOUND;
    }

    Filed under:
  • 04-23-2008 1:37 PM In reply to

    Re: Google ad representative line

    This is common in JS for callbacks.  Not a WTF. 

    < pstorer> Bans don't mean shit on the forum. It's like being on the Sex Offender List. You can still entice kids into your van with candy.

    Want more? Go the IRC channel #TDWTFMafia on irc.slashnet.org.

    Farmer Brown is MasterPlanSoftware. He created a new forum account because he is obsessed with me after I scorned him. Ignoring his trolling is the best way to deal with the crybaby.
  • 04-23-2008 4:21 PM In reply to

    • t-bone
    • Top 500 Contributor
    • Joined on 09-07-2005
    • .be
    • Posts 67

    Re: Google ad representative line

    morbiuswilters:

    This is common in JS for callbacks.  Not a WTF. 

     

    entirely true

  • 04-23-2008 4:36 PM In reply to

    • Saxov
    • Not Ranked
    • Joined on 09-24-2006
    • Aalborg, Denmark
    • Posts 10

    Re: Google ad representative line

    So it is not a WTF that a common JS feature, is to create a method which always return true, and still requires a parameter ?

  • 04-23-2008 4:42 PM In reply to

    Re: Google ad representative line

    Saxov:
    So it is not a WTF that a common JS feature, is to create a method which always return true, and still requires a parameter ?

    I have no idea how callbacks work and am just talking out of my ass.

    FTFY. 

    < pstorer> Bans don't mean shit on the forum. It's like being on the Sex Offender List. You can still entice kids into your van with candy.

    Want more? Go the IRC channel #TDWTFMafia on irc.slashnet.org.

    Farmer Brown is MasterPlanSoftware. He created a new forum account because he is obsessed with me after I scorned him. Ignoring his trolling is the best way to deal with the crybaby.
  • 04-23-2008 4:51 PM In reply to

    • kaamoss
    • Top 500 Contributor
    • Joined on 11-01-2006
    • Irvine Ca
    • Posts 69

    Re: Google ad representative line

    morbiuswilters:

    Saxov:
    So it is not a WTF that a common JS feature, is to create a method which always return true, and still requires a parameter ?

    I have no idea how callbacks work and am just talking out of my ass.

    FTFY. 

     

    Haha well said morbiuswilters, but I think Saxov's post could also be read as"This is why google doesn't want to hire me"

  • 04-23-2008 5:20 PM In reply to

    Re: Google ad representative line

    Could you please enlighten us by illustrating a scenario where a function like

      function foo(a) { return true; }

    must be used but

      function foo2() { return true; }

    ...would not work?

  • 04-23-2008 5:48 PM In reply to

    Re: Google ad representative line

    steamer25:

    Could you please enlighten us by illustrating a scenario where a function like

      function foo(a) { return true; }

    must be used but

      function foo2() { return true; }

    ...would not work?

     

     

    In many GUI frameworks, widgets can generate events of various types. To attach meaning to those events, you pass the widget a function (or object with appropriate function attached) which will be executed once the event occurs. Generally the event will have some kind of information associated with it, which will be passed in to one or more arguments in the function, and you generally need to accept that argument even if you aren't going to make use of it. The true or false return value may decide whether or not the event should stop at this handler or continue being passed up a tree of ancestor widgets. It may for various reasons be handy to have a handler that does nothing other than assert whether the chain should continue. 

  • 04-23-2008 5:57 PM In reply to

    Re: Google ad representative line

    steamer25:

    Could you please enlighten us by illustrating a scenario where a function like

      function foo(a) { return true; }

    must be used but

      function foo2() { return true; }

    ...would not work?

    There is no scenario. The nature of javascript basically states that those two functions are identical, since the method body here doesn't check the arguments. That said, this was probably used as a function pointer somewhere, and the argument is there just for housekeeping.

    function fn1(a) { return a == 'zebra'; }

    function fn2(a) { return true; }

    function doStuff(fn, a) { fn(a); } where fn is fn1 or fn2

    You could make fn2() instead of fn2(a) but this will just be easier for maintainance.

Page 1 of 1 (10 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems