If you like JavaScript this
binding, and the comedy classic Who’s on First?, then is this the mashup for you!
INT. OFFICE - DAY
Two programmers, Phil and Mary, sit at their desks, typing. After a moment, Phil turns to Mary, and shows her a piece of code, which looks like this:
1function showInfo() {
2 return this.name + ' is ' + this.age + ' years old, and has fought ' + this.fights + ' bears.';
3}
4
5var person = {
6 name: 'Sally',
7 age: 43,
8 fights: 16,
9 showInfo: showInfo
10};
PHIL
Hey Mary, you're the JavaScript expert, could you help me learn a few things?
MARY
Sure, what do you want to know?
Phil points to line 1.
PHIL
What's this
here?
Mary points to line 5.
MARY
That.
Phil points again to line 1.
PHIL
No, I want to know what this
is.
Mary points again to line 5.
MARY
I know. It's that.
PHIL
This
(points to line 5)
isn't this
!
(points to line 1)
MARY
Yes it is.
Phil points to both line 1 and line 5.
PHIL
These are two separate things!
MARY
Well, sure.
Phil points to line 1.
PHIL
Right, then what's this
?
Mary points to line 5.
MARY
That.
PHIL
Okay, fine!
Phil points to line 5.
PHIL
What's this
here?
MARY
window
.
PHIL
What? Where?
MARY
Nowhere, it hasn't been called.
PHIL
Then how the hell is that
(points to line 5)
window
?
MARY
Oh, that's not window
, that's an object.
Phil points to line 5.
PHIL
But you just said this
is window
!
MARY
Yeah, that's true.
Phil points to line 5.
PHIL
Then this is window
!
MARY
No, I told you, that is an object.
PHIL
What?
MARY
Look, it's all quite simple.
She points to line 5.
MARY
That is an object.
She points to line 5.
MARY
And this
is window.
PHIL
They're the same thing!
MARY
Only according to typeof
.
PHIL
What?
Slow fade out as they continue to argue.