Archive for the ‘Fleeting Sanity’ Category

The JavaScript Fallacy

April 26th, 2011

As someone with a rampant interest in UI engineering, I work a lot with JavaScript. I’d venture to say that it’s one of my favorite languages, mainly because it’s quick and flexible, but relatively clean…like a cat. Also like a cat, it can be a fickle, fickle beast. Here’s something I ran into yesterday:

// true stuff
0 == false;
1 == true;  

// also true
"0" == false; 
"1" == true;

// to be expected
0 ? true : false == false;

// WTF?
"0" ? true : false == true;

// or in another light
if ("0") { alert("I will show up"); }
if ("0" == true) { alert("I will not"); }

Clearly we have some temperamental1 loose typing. Stupid cats2.

1 This is, not at all, how I thought this word was spelled. From now on, I’m saying temp-er-a-mental.
2 Note, I actually like cats… Even if they are whorish.

A Coder's Guide to Life, Fleeting Sanity

Our new computer overlords

February 21st, 2011