Created
January 13, 2012 21:32
-
-
Save rwaldron/1608810 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JS Today | |
function List() { | |
this.list = [].slice.call(arguments); | |
} | |
List.prototype.diff = function( array ) { | |
return array.filter(function(item) { | |
return !~this.list.indexOf(item); | |
}, this); | |
}; | |
var a = new List(1, 2, 3, 4, 5, 6); | |
a.diff([ 0, 2, 4, 6, 8, 10 ]); | |
// [ 0, 8, 10 ] | |
// Block Lambda and Rest Params | |
function List( ...args ) { | |
this.list = args; | |
} | |
List.prototype.diff = function( array ) { | |
return array.filter({ |item| | |
!~this.list.indexOf(item); | |
}); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ryan that only flies if paren-free makes the cut. I meant to be conservative about what is being illustrated