Nursery Rhyme Code Poem [JavaScript]

(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 content originally appeared on Zach Leatherman and was authored by Zach Leatherman

(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.


This content originally appeared on Zach Leatherman and was authored by Zach Leatherman


Print Share Comment Cite Upload Translate Updates
APA

Zach Leatherman | Sciencx (2007-10-26T05:00:00+00:00) Nursery Rhyme Code Poem [JavaScript]. Retrieved from https://www.scien.cx/2007/10/26/nursery-rhyme-code-poem-javascript/

MLA
" » Nursery Rhyme Code Poem [JavaScript]." Zach Leatherman | Sciencx - Friday October 26, 2007, https://www.scien.cx/2007/10/26/nursery-rhyme-code-poem-javascript/
HARVARD
Zach Leatherman | Sciencx Friday October 26, 2007 » Nursery Rhyme Code Poem [JavaScript]., viewed ,<https://www.scien.cx/2007/10/26/nursery-rhyme-code-poem-javascript/>
VANCOUVER
Zach Leatherman | Sciencx - » Nursery Rhyme Code Poem [JavaScript]. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2007/10/26/nursery-rhyme-code-poem-javascript/
CHICAGO
" » Nursery Rhyme Code Poem [JavaScript]." Zach Leatherman | Sciencx - Accessed . https://www.scien.cx/2007/10/26/nursery-rhyme-code-poem-javascript/
IEEE
" » Nursery Rhyme Code Poem [JavaScript]." Zach Leatherman | Sciencx [Online]. Available: https://www.scien.cx/2007/10/26/nursery-rhyme-code-poem-javascript/. [Accessed: ]
rf:citation
» Nursery Rhyme Code Poem [JavaScript] | Zach Leatherman | Sciencx | https://www.scien.cx/2007/10/26/nursery-rhyme-code-poem-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.