Sun Oct 21
#
dil•a•to•ry
[dil-uh-tawr-ee ]
— adjective
1. Tending to delay or procrastinate; slow; tardy.
2. Intended to cause delay, gain time, or defer decision.
3. Using cautious slow strategy to wear down opposition; avoiding direct confrontation.
2. Intended to cause delay, gain time, or defer decision.
3. Using cautious slow strategy to wear down opposition; avoiding direct confrontation.
#
Splat function arguments in JavaScript with Prototype 1.6.0
Object.extend(Function.prototype, (function() {
function splat(args, index) {
var result = new Array(index);
for (var i = 0; i < index; i++)
result[i] = args.shift();
return result.concat([args]);
}
return {
splatterize: function() {
var names = this.argumentNames();
if (names.last() != "$args") return this;
return this.wrap(function() {
var a = $A(arguments), orig = a.shift();
return orig.apply(null,
splat(a, names.length - 1));
});
}
};
})());
var x = (function(a, b, $args) {
return { a: a, b: b, $args: $args };
}).splatterize();
// x(1) => { a: 1, $args: [] }
// x(1, 2) => { a: 1, b: 2, $args: [] }
// x(1, 2, 3) => { a: 1, b: 2, $args: [3] }
// x(1, 2, 3, 4) => { a: 1, b: 2, $args: [3, 4] }