Skip to content

Instantly share code, notes, and snippets.

@gilesbowkett
Created October 18, 2010 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilesbowkett/631750 to your computer and use it in GitHub Desktop.
Save gilesbowkett/631750 to your computer and use it in GitHub Desktop.
wtf_null.js
var sys = require('sys'),
assert = require('assert'),
underscore = require('../vendor/underscore/underscore')._;
Array.prototype.drop = function() {
var recalculatedArray = _.compact(this);
for (var i = recalculatedArray.length; i < 7; i++) {
recalculatedArray[i] = null;
}
return recalculatedArray;
}
assert.ok(null == [null, 1, 2, 3, 4, 5, 6].drop()[6]);
assert.deepEqual([1, 2, 3, 4, 5, 6, null],
[null, 1, 2, 3, 4, 5, 6].drop());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment