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".
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".
The following convert to false when applied to a double negation in JavaScript:
""
null
undefined
0
NaN
"... 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
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.
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.
It is a sign of the times when you find out through Facebook your high school best friend got engaged.
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.
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.
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);
"I've heard JPGs are smaller than BMPs, so I'll just change the extension!"