• January 24, 2010

    This will alert "10":
    var num = num || 10;
    alert(num);

    But so will this:
    num = 0;
    var num = num || 10;
    alert(num);

    Watch out for the cases where num is "falsey".

  • January 23, 2010

    The following convert to false when applied to a double negation in JavaScript:
    ""
    null
    undefined
    0
    NaN

  • January 22, 2010

    "... if you try to return anything [from a constructor] that is not an object [emphasis mine], the constructor will proceed with its usual behavior and return this."
    From Object-Oriented JavaScript by Stoyan Stefanov

  • December 29, 2009

    I was reading Juriy Zaytsev's (@kangax) article "Optimizing HTML" and had a few comments.

    1. I have used <!CDATA[...]> sections when I'm embedding "<" and ">" but I think that's just because I've used XSL before and they have caused problems when performing transformations. But I'll try to remove it from my HTML as he suggests.

    2. If I don't have a URL to use in the href attribute, I'll still use "javascript:void(0)" because I really don't like the hash being added to my URL. Perhaps I should just add some jQuery code:

    $("a[href='#']").click(function(){return false;});

    That's 49 characters, so I would have to change only 3 links to use the hash instead of "javascript:void(0)" to save space.

  • December 28, 2009

    Alyssa [to Christi]: I know what I'm getting at Grandma and Grandad's house!
    Christi: What?
    Alyssa: A movie.
    Christi: How do you know that?
    Alyssa: Because daddy shook it.

  • November 30, 2009

    It is a sign of the times when you find out through Facebook your high school best friend got engaged.

  • November 30, 2009

    Anyone have a funny Thanksgiving quote? The only one I can remember was from my brother: "I'm only friends [on Facebook] with people I don't know." It was also funny to see my face popup on his Droid.

    I also was reminded of how much I love my wife. Since she didn't come to my parents at the same time I did, I waited until she showed. At one point we all heard the door open and my mom said that is was probably "Chris". I immediately got excited because I thought it was my wife instead of my brother. (Sorry Chris!)

    Lexi celebrated her 10th birthday this Thanksgiving! (The big one-oh. Double digits.) We gave her treats and lots of love.

  • November 20, 2009

    Dr. Pepper sent me a "year's worth" in the form of 24 free 12-pack coupons. First of all, that's only 288 days if drink 1 Dr. Pepper a day, which is typical for me. Secondly, I got the coupons November 19th, 2009 and they expire December 31, 2009. Come on Dr. Pepper and M80.

    Tags:
  • November 15, 2009

    Kids = (Adam + Christi).copy();
    Parents = Adam.getParents();
    Duration = create(Saturday.night, Sunday.morning);
    Parents.watch(Kids).for(Duration);
    if (Behavior.good(Kids))
        Adam.addResponsibility(get(Kids));
    else
        Parents.shorten(Duration);
        Parents.addResponsibility(remove(Kids)).wait(0);

  • November 12, 2009
    BMP or JPG

    I've heard JPGs are smaller than BMPs, so I'll just change the extension!

    "I've heard JPGs are smaller than BMPs, so I'll just change the extension!"