Zach’s ugly mug (his face) Zach Leatherman

Nursery Rhyme Code Poem [JavaScript]

October 26, 2007
(function()
{
    function BlindMouse() {}
    BlindMouse.prototype.tail = true;
    BlindMouse.prototype.run = function(after) {};

    function Mice(mouse1, mouse2, mouse3)
    {
        this.mice = [];
        this.mice.push(mouse1, mouse2, mouse3);
        this.declare = function()
        {
            return this.mice.length + ' Blind Mice';
        };
        this.run = function(after)
        {
            for(var j=0,k=this.mice.length;j<k ;j++) {
                this.mice[j].run(after);
            }
        };
        this.cutOff = function(prop, weapon)
        {
            for(var j=0,k=this.mice.length;j<k;j++) {
                this.mice[j][prop] = false;
            }
        };
    }

    var mice = new Mice(new BlindMouse(), new BlindMouse(), new BlindMouse());
    alert(mice.declare());
    alert(mice.declare());

    function seeHow(they, func)
    {
        they[func]();
    }

    seeHow(mice, 'run');
    seeHow(mice, 'run');

    var farmersWife = function()
    {
        var weapon = 'Carving Knife';
        return {
            cutOff: function(creatures, prop)
            {
                creatures.cutOff('tail', weapon);
            }
        }
    }();

    mice.run(farmersWife);

    farmersWife.cutOff(mice, 'tail');

    function haveYouSeen(obj, timeSpan)
    {
        return true;
    }

    if(haveYouSeen('Such a Thing', 'Your Life')) {
        alert('as ' + mice.declare() + '?');
    }
}());

The above code poem is released under the BSD license. To use in production environment without error, please enclose with a try-catch block. Obviously I’m kidding, don’t use this code. Not even for enterprise software.


< Newer
Nursery Rhyme Code Poem [PHP]
Older >
Write More Efficient Javascript in YUI with CSS Selectors

Zach Leatherman IndieWeb Avatar for https://zachleat.com/is a builder for the web at IndieWeb Avatar for https://fontawesome.com/Font Awesome and the creator/maintainer of IndieWeb Avatar for https://www.11ty.devEleventy (11ty), an award-winning open source site generator. At one point he became entirely too fixated on web fonts. He has given 84 talks in nine different countries at events like Beyond Tellerrand, Smashing Conference, Jamstack Conf, CSSConf, and The White House. Formerly part of CloudCannon, Netlify, Filament Group, NEJS CONF, and NebraskaJS. Learn more about Zach »

1 Comment
  1. Sachin Jani Disqus

    16 Jul 2016
    Haha Damn that's super cool . :D
Shamelessly plug your related post

These are webmentions via the IndieWeb and webmention.io.

Sharing on social media?

This is what will show up when you share this post on Social Media:

How did you do this? I automated my Open Graph images. (Peer behind the curtain at the test page)