I was perusing the source code for Dean Edwards’ base2 library when I discovered that functions can access the parameters of other functions in the call stack. My mind immediately started spinning, imagining the convoluted code this would allow.
Here’s one to get you started:
function checkArgTypes(/*expected types*/) {
var callerArgs = arguments.callee.caller;
if (callerArgs.length !== arguments.length) {
throw new Error('checkArgTypes does not have enough arguments.');
}
for (var i = 0; i < arguments.length; i++) {
if (typeof callerArgs[i] !== arguments[i]) {
throw new Error('Argument ' + (i+1) + ' is of type ' + typeof callerArgs[i] + ' but should be of type ' + arguments[i] + '.');
}
}
}
function run(str, num, bool) {
checkArgTypes('string', 'number', 'boolean');
}
You might want to try it out in jconsole.
And, of course, you can’t ignore the obligatory security implications:
function validateUser(username, password) {
/* accidentally call trojan function */
trojan();
}
function trojan() {
alert('Your password is ' + validateUser[1] + '.');
}
validateUser('user', 'secret');
Ahh, well. I’d best get back to writing real code.
NOTE: Edited to fix WordPress source code formatting problem.
Update: Fixed a typo in my “for” loop. (Thanks Philippe!)
It seems Half.com offers steep discounts on some of its products. Here’s an example search result:

You pay $85.14 and you still save 99%? Here’s the product listing:

Oh, sure it’s worth $99,999.00!
I was a bit surprised when I saw Amazon’s breath-taking offer while shopping for a DVI adapter for my MacBook:

This evening I got a spam comment on my recent post about Akismet spam filtering, and I thought it was too ironic to delete. The spam must have been triggered by the following sentence:
If Akismet reports a comment as spam, the comment is stored with a special “spam” comment type and the e-mail notification contains a bold “**SPAM**” in the subject. If an item is incorrectly flagged as spam, I can use the MySQL client or online administrator to turn it into a real comment.
The nascar flags spammer wrote:
I have a giant flag collection. I am thinking of starting a blog about its history. Now I am just doing research…thanks.
To which I responded:
Glad to be of help, nascar flags. I don’t know much about flags, but I’m pretty good at flagging spam. Sorry I had to remove the link to your website.
While you do your research, you might try limiting your comments to blog posts containing “flag” but not “spam”.
If you want me to keep your spam comments on my blog, try shooting yourself in the foot.
I just received four copies of Chad Fowler’s book My Job Went to India: 52 Ways to Save Your Job from Amazon. I laughed out loud when I opened the box. Is Amazon offering the 53rd way to save your job?
I laughed even harder when I removed the paper wrapper. Where in the book was that? Maybe Chad Fowler didn’t endorse this promotional item after all.

