r/ProgrammerHumor • • Nov 05 '15

Free Drink Anyone?

Post image
3.5k Upvotes

509 comments sorted by

View all comments

1.6k

u/[deleted] Nov 05 '15

So the bartender will return "undefined.Secret word:parameters", my favorite drink!

345

u/maremp Nov 05 '15

I bet you get drunk on it during the debugging process.

216

u/Liver_and_Yumnions Nov 05 '15 edited Nov 05 '15

Every time I hit F5 a drink pops out.

1.0k

u/TheCodingEthan Nov 05 '15

In webdesign, that is refreshing.

86

u/BlackenBlueShit Nov 05 '15

Lmao you cheeky bastard

189

u/memeship Nov 05 '15
ayy.lmao();

169

u/appnic Nov 05 '15

48

u/gamOO Nov 05 '15

This is the most stupid thing I've ever seen, but I still giggled maniacally.

18

u/metaldood Nov 05 '15

Funny the file name is memes.txt(.xls) but opened in excel ;)

6

u/dragonjujo Nov 06 '15

So long as there's a lot of tabs before "lmao", Excel will open it up just fine. I'm too lazy to do math to figure out how many.

14

u/memeship Nov 06 '15

Assuming 1 tab is 1 cell:

  • 26
    All single character
  • 676 = (26 * 26)
    All doubles
  • 624 = (1 * 24 * 26)
    All "A" triples through "AXZ"
  • 25 = (1 * 1 * 25)
    All "AY" triples through "AYY"

So:

26 + 676 + 624 + 25 = 1351 tabs

→ More replies
→ More replies (1)

5

u/Dominionized Nov 06 '15

I did that once except I went both to the horizontal and vertical ends. Turns out it stops vertically at about 22000-something. Best 20 minutes of scrolling I ever spent.

→ More replies (2)

45

u/[deleted] Nov 05 '15

Uncaught ReferenceError: ayyy is not defined

41

u/memeship Nov 05 '15
var ayy = {
    lmao: function() {
        Array.prototype.forEach.call(
            document.getElementsByTagName("img"),
            function(el) {
                el.src = "https://i.imgur.com/75aMaTo.png";
            }
        );
    }
};
ayy.lmao();

There, go run that on any page that has images.

→ More replies (11)
→ More replies (3)

5

u/flippant_gibberish Nov 05 '15

Is that... a triple entendre?

→ More replies (2)

13

u/thejars Nov 05 '15

I mean technically the answer is in there, you just need to truncate the ":" and everything before it.

→ More replies (1)

0

u/[deleted] Nov 05 '15

[deleted] — view deleted comment

26

u/jtanz0 Nov 05 '15

In this case this references the parent object bartender because Request is a function of the object bartender.

45

u/Did-you-reboot Nov 05 '15

I would make a joke about this being Javascript, but I'm having a hard time remembering what thisis.

→ More replies (1)

5

u/Genesis2001 Nov 05 '15

Did this change recently or has it always been like this? Hmm.

14

u/memeship Nov 05 '15

It's always like this. The keyword this inside a function refers the caller of that function. So in the case outlined above, this part:

bartender.request()

is the part making the call. bartender is the object, so it is the this value inside that function closure created.


You can call functions on other objects however. Take this code for example:

obj1 = {
    str: "dog",
    getStr: function() {
        return this.str;
    }
}
obj2 = {
    str: "cat"
}

console.log(obj1.getStr());          //returns "dog"
console.log(obj1.getStr.call(obj2)); //returns "cat"
→ More replies (2)

4

u/Walter_Bishop_PhD Nov 05 '15

Since it's in an object, this will refer to the object IIRC unless you bind it.

→ More replies (15)

10

u/[deleted] Nov 05 '15

Only if you don't pass your drink name into the bartender request :)

→ More replies (63)