Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var arr = [];
- for (var i = 0; i < 1000; i++) {
- arr.push(i);
- if (i > 0 && i % 10 == 0) {
- arr.push(i - 10);
- }
- }
- // https://twitter.com/judofyr/status/83901970494144513
- Array.prototype.judofyr=function(a,r,c,d,i){for(a=this.sort(),i=0,r=[a[i]];c=a[i++],d=a[i],i<this.length;)c===d||r.push(d);return r}
- // https://twitter.com/WebReflection/status/83867362490720258
- Array.prototype.WebReflection=function(a){return function(){return this.filter(a)}}(function(a,b,c){return c.indexOf(a,b+1)<0});
- // https://gist.github.com/1042640
- Array.prototype.abozhilov = (function () {
- var TYPE_MAP = {
- 'object' : 1,
- 'function' : 1
- }
- return function () {
- var map = {},
- objects = [],
- unique = [];
- for (var i = 0, len = this.length; i < len; i++) {
- var val = this[i];
- if (TYPE_MAP[typeof val] && val) {
- if (!val.__unique__) {
- unique.push(val);
- objects.push(val);
- val.__unique__ = 1;
- }
- }
- else if (!map[val]) {
- unique.push(val);
- map[val] = 1;
- }
- }
- for (i = objects.length; i--;) {
- delete objects[i].__unique__;
- }
- return unique;
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement