JavaScript Variable Declarations
This one is for the JavaScript nerds. No suspense as I’ve included the answer below the question.
NOTE: This is lame-ass, test code. Anyone who codes like this should be shot, or at least have your eyes taped open and be forced to watch Gigli three times.
But I wanted to remind myself how variable declaration, definition, and (non-)block level scoping worked in a basic JavaScript function.
Ready, set, go:
// What strings will be displayed in the 4 alert statements?
//
// This is designed to be a test, not a trick.
function test() {
i = 20;
alert(i);
alert(window.i);
if (true) {
var i = {};
}
alert(i);
}
test();
alert(window.i);
Answers for the impatient:
- 20
- undefined
- [object Object]
- undefined
My JavaScript reminders:
- Variables have functional scope or global scope. There is no block level scope in JavaScript. Sometimes I need to see it to be reminded of it.
- If a variable is declared with var within a function, no matter where it is delcared, all references to that variable are local, not global.
- Local variable declaration is always promoted and takes precedence over any potential global (e.g. window object) variable declaration. That’s why both references of window.i are still undefined.
- Variable assignment still happens along the flow of control within the function. Hence the first alert(i) is 20, not [object Object].
If anyone is a JavaScript nerd and you happen to stumble in on this post, please feel free to post anything I forgot.
The Mixcloud Countdown
I might have seen this before today, but the question mark following the number caught my attention this morning:
It’s seemingly a countdown of the number of mixes listened to on Mixcloud. It’s most likely going to one million. I have no idea what’s going to happen when it gets to one million. It’s also a great excuse to write something other than JavaScript.
I ran into this site last September reading an article on one of my favorite blogs. I don’t rave, don’t even dance, am not very stylish, and I don’t have the DJ lingo down. But I hope I’m the millionth listener, and am looking forward to seeing what happens.
Dear Bank of America, do you care about your money and my identity?
Dear Bank of America,
I’ve spent about a half hour that I don’t really have this morning sorting out why I received 4 request for unlock codes in my email. I don’t even have an account with you anymore, and I’d like to know why someone can seemingly attempt to “log in” as me when I thought I deactivated everything.
As a concerned citizen, I’ve attempted to get through on three of your phone numbers. None of your phone numbers are the equivalent of an action line for people like me who need to report a possible emergency.
I understand you are probably understaffed, but I have this feeling that if I tag this blog post correctly, you’ll probably respond quickly and appropriately… or maybe not, we shall see.
Leave a comment here, and it will be forwarded to me.
- Jeremy
EDIT: After poking around on their website, I found their solution for fraudulent emails. Send all fraudulent and fishing emails to abuse@bankofamerica.com.
Jeremy joins the cloud
I love technology. For all of this love, I rarely embrace nerdtastic things that cross my blog reader. Most of the amazing, technological breakthroughs happened long before my trip down the birth canal.
And, I’m usually the last to jump on any band wagon. When I hear the term Matrix Cloud I chuckle to myself and think of Larry Ellison’s most wonderful rant.
But today I join the cloud in what I consider the first real way. The coolness of this cloud is both conceptual and kinetically different than just client-server technology. The secret sauce of the cloud is accessibility, in a way that occurs as extremely low pain to the senses of those doing the accessing.
Today I joined delicious.com, and you can find me at http://delicious.com/jeremyosborne. All my bookmarks are private, but I’ll make them public soon once I get used to managing things.
Dear public diary
It’s interesting keeping a public diary, which is how I view my personal web log. December is always a year of reflection, and this month of this 2009th CE year is no different.
I don’t really have anything to talk about anymore. Over the last year I thought I might come up with one last thing, something that was actually worth a million dollars, something that garnered a million views, something that was really important.
Nothing important really comes out of my mouth. Ever. Don’t feel bad, dear reader, to learn this is one of the best bits of education I’ve ever received. Those who like to dwell on the various philosophies of life know the outcome of such a self-realization: if I have nothing to say at all, absolutely nothing if import, and I realize this, then I am free to say anything.
What will happen now? Probably more of the same, unless of course, it’s not.
Quote of the day
“I didn’t say whiteboy, I said whiteboard!”
[Response to a purposefully misinterpreted subject for a photo.]
Subtle Humor
Grooveshark.com, a music streaming site, delivers data through a few different sub-domains. My favorite:
cowbell.grooveshark.com
God called….
He rang me up on my cell on non-peak (thank God) hours. I was like, no shit, God is calling me? On my cell phone? And he was like,
“Dude nothing supernatural works anymore. Burning a bush is so environmentally non-friendly. Make a lawn circle and people act like I’ve raped their dog. I could have done another Kevin Smith movie, but I figured I’d try a phone campaign.”
“No way?”
“Way! G1 all the way, love that little keyboard. I’m even getting the whole texting thing down. LOL! KIT!”
“But why are you calling me?”
“To shoot the shit.”
“Really?”
“Yeah. So what you doing?… Ha ha, I’m God! Of course I know what you’re doing. In fact, remember all those times you promised me that if I didn’t crash the airplane you wouldn’t masturbate anymore?”
I took my hands off the keyboard.
“You’re so busted. Liar liar, pants on fire.”
My face was totally red. “Umm….”
“Haha, just messing with you. What do I care if you give a new meaning to free range chicken. I got so much bigger fish to fry. Like my flock, they are so far astray right now, I figured I’d ring up all you heathens.”
“So, what about…”
“No.”
“And…”
“Yes.”
“Ummm…. God, do you actually want me to talk?”
“Dude, sorry, it’s this omniscient thing, you know?”
“So you don’t actually talk to them?”
“Hell NO! They lost privileges! They try so hard with their shallow prayers, but oh lordy! I hear them and I pretend I have a headache.”
“Were you really going to let her into the white house?”
“Not my job, that’s your job. Nice work though, kept me from having to wash the planet clean again.”
It was so awkward, but there I was, watching the clock tick by as God was chatting away before I heard him say, “blah blah bla, oh good, you’re back. I know you gotta go. You’re always busy, but I like to talk, too. Ha ha! Anyway, time to give Rev. White a call, pretend I’m Al Sharpton and record the whole thing for Youtube. Talk about viral. Late!”
Pigs
I love bacon. Yesterday, while eating some bacon Ice Cream that my wife made, I thought about how pigs are generally considered to be intelligent, yet they love to wallow in their own shit.
I wondered if perhaps they happily root around in the dirt is because pigs are intelligent enough to realize they are nothing more than animals, and perhaps they are wise enough not to try to be anything more than that.
Whether they are filthy through ignorance or honesty matters not, as bacon in all its forms is damn good.
Design Wisdom
Excellent design wisdom. I stole this from the most excellent post by the Angry Aussie.

Design Wisdom
